From bfcbb2132d78a1fdb63bc1ce7a71068c2ec89c56 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 24 Aug 2018 10:49:34 +0200 Subject: [PATCH] #3269 Compdat Export Performance : Use const access for fracture export --- .../RicExportFractureCompletionsImpl.cpp | 59 +++++++++----- .../RicExportFractureCompletionsImpl.h | 22 +++-- ...ellPathExportCompletionDataFeatureImpl.cpp | 80 ++++++++++--------- 3 files changed, 98 insertions(+), 63 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp index af168c9612..01a5e7331d 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp @@ -63,7 +63,7 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat std::vector* fractureDataForReport, QTextStream* outputStreamForIntermediateResultsText) { - std::vector fracturesAlongWellPath; + std::vector fracturesAlongWellPath; if (wellPath->fractureCollection()->isChecked()) { @@ -100,7 +100,7 @@ std::vector for (size_t branchIndex = 0; branchIndex < branches.size(); ++branchIndex) { - std::vector fractures; + std::vector fractures; for (RimSimWellFracture* fracture : well->simwellFractureCollection->simwellFractures()) { if (fracture->isChecked() && static_cast(fracture->branchIndex()) == branchIndex) @@ -125,7 +125,7 @@ std::vector RicExportFractureCompletionsImpl::generateCompdatValues(RimEclipseCase* caseToApply, const QString& wellPathName, const RigWellPath* wellPathGeometry, - const std::vector& fractures, + const std::vector& fractures, std::vector* fractureDataReportItems, QTextStream* outputStreamForIntermediateResultsText) { @@ -136,16 +136,6 @@ std::vector return fractureCompletions; } - double cDarcyInCorrectUnit = RiaEclipseUnitTools::darcysConstant(caseToApply->eclipseCaseData()->unitsType()); - const RigMainGrid* mainGrid = caseToApply->eclipseCaseData()->mainGrid(); - - // To handle several fractures in the same eclipse cell we need to keep track of the transmissibility - // to the well from each fracture intersecting the cell and sum these transmissibilities at the end. - // std::map > - // std::map> eclCellIdxToTransPrFractureMap; - - std::vector> sharedComplForFracture(fractures.size()); - { // Load the data required by computations to be able to use const access only inside OpenMP loop @@ -182,12 +172,43 @@ std::vector caseToApply->loadStaticResultsByName(resultNames); } + return generateCompdatValuesConst(caseToApply, wellPathName, wellPathGeometry, fractures, fractureDataReportItems, outputStreamForIntermediateResultsText); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicExportFractureCompletionsImpl::generateCompdatValuesConst( + const RimEclipseCase* caseToApply, + const QString& wellPathName, + const RigWellPath* wellPathGeometry, + const std::vector& fractures, + std::vector* fractureDataReportItems, + QTextStream* outputStreamForIntermediateResultsText) +{ + std::vector fractureCompletions; + + if (!caseToApply || !caseToApply->eclipseCaseData()) + { + return fractureCompletions; + } + + double cDarcyInCorrectUnit = RiaEclipseUnitTools::darcysConstant(caseToApply->eclipseCaseData()->unitsType()); + const RigMainGrid* mainGrid = caseToApply->eclipseCaseData()->mainGrid(); + + // To handle several fractures in the same eclipse cell we need to keep track of the transmissibility + // to the well from each fracture intersecting the cell and sum these transmissibilities at the end. + // std::map > + // std::map> eclCellIdxToTransPrFractureMap; + + std::vector> sharedComplForFracture(fractures.size()); + // Temporarily commented out due to sync problems. Needs more analysis //#pragma omp parallel for for (int i = 0; i < (int)fractures.size(); i++) { - RimFracture* fracture = fractures[i]; - RimFractureTemplate* fracTemplate = fracture->fractureTemplate(); + const RimFracture* fracture = fractures[i]; + const RimFractureTemplate* fracTemplate = fracture->fractureTemplate(); if (!fracTemplate) continue; @@ -199,9 +220,9 @@ std::vector // If finite cond chosen and conductivity not present in stimplan file, do not calculate trans for this fracture if (useFiniteConductivityInFracture) { - if (dynamic_cast(fracTemplate)) + auto fracTemplateStimPlan = dynamic_cast(fracTemplate); + if (fracTemplateStimPlan) { - RimStimPlanFractureTemplate* fracTemplateStimPlan = dynamic_cast(fracTemplate); if (!fracTemplateStimPlan->hasConductivity()) { RiaLogging::error("Trying to export completion data for stimPlan fracture without conductivity data for " + @@ -428,7 +449,7 @@ std::vector double height = 0.0; double halfLength = 0.0; { - auto* ellipseTemplate = dynamic_cast(fracTemplate); + auto* ellipseTemplate = dynamic_cast(fracTemplate); if (ellipseTemplate) { conductivity = ellipseTemplate->conductivity(); @@ -437,7 +458,7 @@ std::vector halfLength = ellipseTemplate->halfLength(); } - auto* stimplanTemplate = dynamic_cast(fracTemplate); + auto* stimplanTemplate = dynamic_cast(fracTemplate); if (stimplanTemplate) { conductivity = stimplanTemplate->areaWeightedConductivity(); diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.h index b69b1f6be3..0de2748352 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.h @@ -47,10 +47,20 @@ public: const RimSimWellInView* well, QTextStream* outputStreamForIntermediateResultsText); - static std::vector generateCompdatValues(RimEclipseCase* caseToApply, - const QString& wellPathName, - const RigWellPath* wellPathGeometry, - const std::vector& fractures, - std::vector* fractureDataForReport, - QTextStream* outputStreamForIntermediateResultsText); + static std::vector + generateCompdatValues(RimEclipseCase* caseToApply, + const QString& wellPathName, + const RigWellPath* wellPathGeometry, + const std::vector& fractures, + std::vector* fractureDataReportItems, + QTextStream* outputStreamForIntermediateResultsText); + +private: + static std::vector + generateCompdatValuesConst(const RimEclipseCase* caseToApply, + const QString& wellPathName, + const RigWellPath* wellPathGeometry, + const std::vector& fractures, + std::vector* fractureDataReportItems, + QTextStream* outputStreamForIntermediateResultsText); }; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index ae421ce8cd..6a5e4f00d7 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -446,7 +446,7 @@ void RicWellPathExportCompletionDataFeatureImpl::generateWelsegsTable(RifEclipse formatter.header(header); } - { + { double prevMD = exportInfo.initialMD(); double prevTVD = exportInfo.initialTVD(); for (const RicMswSegment& location : exportInfo.wellSegmentLocations()) @@ -484,8 +484,8 @@ void RicWellPathExportCompletionDataFeatureImpl::generateWelsegsTable(RifEclipse } { - generateWelsegsSegments(formatter, exportInfo, { RigCompletionData::ICD, RigCompletionData::FISHBONES}); - generateWelsegsSegments(formatter, exportInfo, { RigCompletionData::FRACTURE }); + generateWelsegsSegments(formatter, exportInfo, {RigCompletionData::ICD, RigCompletionData::FISHBONES}); + generateWelsegsSegments(formatter, exportInfo, {RigCompletionData::FRACTURE}); } formatter.tableCompleted(); @@ -523,16 +523,16 @@ void RicWellPathExportCompletionDataFeatureImpl::generateWelsegsSegments( formatter.add(0); // Depth change formatter.add(exportInfo.linerDiameter()); formatter.add(exportInfo.roughnessFactor()); - formatter.rowCompleted(); + formatter.rowCompleted(); } else { if (completion.completionType() == RigCompletionData::FISHBONES) { formatter.comment(QString("%1 : Sub index %2 - %3") - .arg(segment.label()) - .arg(segment.subIndex()) - .arg(completion.label())); + .arg(segment.label()) + .arg(segment.subIndex()) + .arg(completion.label())); } else if (completion.completionType() == RigCompletionData::FRACTURE) { @@ -541,17 +541,17 @@ void RicWellPathExportCompletionDataFeatureImpl::generateWelsegsSegments( for (const RicMswSubSegment& subSegment : completion.subSegments()) { - double depth = 0; + double depth = 0; double length = 0; if (exportInfo.lengthAndDepthText() == QString("INC")) { - depth = subSegment.deltaTVD(); + depth = subSegment.deltaTVD(); length = subSegment.deltaMD(); } else { - depth = subSegment.startTVD() + subSegment.deltaTVD(); + depth = subSegment.startTVD() + subSegment.deltaTVD(); length = subSegment.startMD() + subSegment.deltaMD(); } double diameter = segment.effectiveDiameter(); @@ -574,7 +574,9 @@ void RicWellPathExportCompletionDataFeatureImpl::generateWelsegsSegments( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::generateWelsegsCompletionCommentHeader(RifEclipseDataTableFormatter &formatter, RigCompletionData::CompletionType completionType) +void RicWellPathExportCompletionDataFeatureImpl::generateWelsegsCompletionCommentHeader( + RifEclipseDataTableFormatter& formatter, + RigCompletionData::CompletionType completionType) { if (completionType == RigCompletionData::CT_UNDEFINED) { @@ -601,21 +603,21 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompsegTables(RifEclips const RicMswExportInfo& exportInfo) { /* - * TODO: Creating the regular perforation COMPSEGS table should come in here, before the others - * should take precedence by appearing later in the output. See #3230. - */ + * TODO: Creating the regular perforation COMPSEGS table should come in here, before the others + * should take precedence by appearing later in the output. See #3230. + */ { - std::set fishbonesTypes = { RigCompletionData::ICD, RigCompletionData::FISHBONES }; + std::set fishbonesTypes = {RigCompletionData::ICD, RigCompletionData::FISHBONES}; generateCompsegTable(formatter, exportInfo, false, fishbonesTypes); if (exportInfo.hasSubGridIntersections()) { generateCompsegTable(formatter, exportInfo, true, fishbonesTypes); } } - + { - std::set fractureTypes = { RigCompletionData::FRACTURE }; + std::set fractureTypes = {RigCompletionData::FRACTURE}; generateCompsegTable(formatter, exportInfo, false, fractureTypes); if (exportInfo.hasSubGridIntersections()) { @@ -627,10 +629,11 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompsegTables(RifEclips //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::generateCompsegTable(RifEclipseDataTableFormatter& formatter, - const RicMswExportInfo& exportInfo, - bool exportSubGridIntersections, - const std::set& exportCompletionTypes) +void RicWellPathExportCompletionDataFeatureImpl::generateCompsegTable( + RifEclipseDataTableFormatter& formatter, + const RicMswExportInfo& exportInfo, + bool exportSubGridIntersections, + const std::set& exportCompletionTypes) { bool generatedHeader = false; @@ -665,7 +668,8 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompsegTable(RifEclipse formatter.add(intersection.gridName()); } cvf::Vec3st ijk = intersection.gridLocalCellIJK(); - formatter.addZeroBasedCellIndex(ijk.x()).addZeroBasedCellIndex(ijk.y()).addZeroBasedCellIndex(ijk.z()); + formatter.addZeroBasedCellIndex(ijk.x()).addZeroBasedCellIndex(ijk.y()).addZeroBasedCellIndex( + ijk.z()); formatter.add(completion.branchNumber()); double startLength = segment.startMD(); @@ -714,7 +718,7 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompsegHeader(RifEclips } { - std::vector header = { RifEclipseOutputTableColumn("Name") }; + std::vector header = {RifEclipseOutputTableColumn("Name")}; formatter.header(header); formatter.add(exportInfo.wellPath()->name()); formatter.rowCompleted(); @@ -727,15 +731,15 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompsegHeader(RifEclips allHeaders.push_back(RifEclipseOutputTableColumn("Grid")); } - std::vector commonHeaders = { RifEclipseOutputTableColumn("I"), - RifEclipseOutputTableColumn("J"), - RifEclipseOutputTableColumn("K"), - RifEclipseOutputTableColumn("Branch no"), - RifEclipseOutputTableColumn("Start Length"), - RifEclipseOutputTableColumn("End Length"), - RifEclipseOutputTableColumn("Dir Pen"), - RifEclipseOutputTableColumn("End Range"), - RifEclipseOutputTableColumn("Connection Depth") }; + std::vector commonHeaders = {RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K"), + RifEclipseOutputTableColumn("Branch no"), + RifEclipseOutputTableColumn("Start Length"), + RifEclipseOutputTableColumn("End Length"), + RifEclipseOutputTableColumn("Dir Pen"), + RifEclipseOutputTableColumn("End Range"), + RifEclipseOutputTableColumn("Connection Depth")}; allHeaders.insert(allHeaders.end(), commonHeaders.begin(), commonHeaders.end()); formatter.header(allHeaders); } @@ -1418,10 +1422,10 @@ RicMswExportInfo RicWellPathExportCompletionDataFeatureImpl::generateFracturesMs //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicMswExportInfo RicWellPathExportCompletionDataFeatureImpl::generateFracturesMswExportInfo( - RimEclipseCase* caseToApply, - const RimWellPath* wellPath, - const std::vector& fractures) +RicMswExportInfo + RicWellPathExportCompletionDataFeatureImpl::generateFracturesMswExportInfo(RimEclipseCase* caseToApply, + const RimWellPath* wellPath, + const std::vector& fractures) { const RigMainGrid* grid = caseToApply->eclipseCaseData()->mainGrid(); @@ -1491,8 +1495,8 @@ RicMswExportInfo RicWellPathExportCompletionDataFeatureImpl::generateFracturesMs { cvf::Vec3d position = wellPath->wellPathGeometry()->interpolatedPointAlongWellPath(fractureStartMD); - std::vector fractureVector(1, fracture); - std::vector completionData = + std::vector fractureVector(1, fracture); + std::vector completionData = RicExportFractureCompletionsImpl::generateCompdatValues(caseToApply, wellPath->completions()->wellNameForExport(), wellPath->wellPathGeometry(),