//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QString Rim3dOverlayInfoConfig::resultInfoText(const HistogramData& histData, RimGeoMechView* geoMechView) { QString infoText; if (geoMechView) { RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : nullptr; bool isResultsInfoRelevant = caseData && geoMechView->hasUserRequestedAnimation() && geoMechView->cellResultResultDefinition()->hasResult(); if (isResultsInfoRelevant) { QString resultPos; QString fieldName = geoMechView->cellResultResultDefinition()->resultFieldUiName(); QString compName = geoMechView->cellResultResultDefinition()->resultComponentUiName(); switch (geoMechView->cellResultResultDefinition()->resultPositionType()) { case RIG_NODAL: resultPos = "Nodal"; break; case RIG_ELEMENT_NODAL: resultPos = "Element nodal"; break; case RIG_INTEGRATION_POINT: resultPos = "Integration point"; break; case RIG_ELEMENT: resultPos = "Element"; break; default: break; } if (compName == "") { infoText += QString("<b>Cell result:</b> %1, %2").arg(resultPos).arg(fieldName); } else { infoText += QString("<b>Cell result:</b> %1, %2, %3").arg(resultPos).arg(fieldName).arg(compName); } infoText += QString("<br><b>Statistics:</b> ") + m_statisticsTimeRange().uiText() + " and " + m_statisticsCellRange().uiText(); infoText += QString("<table border=0 cellspacing=5 >" "<tr> <td>Min</td> <td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> <td>Sum</td> </tr>" "<tr> <td>%1</td> <td> %2</td> <td> %3</td> <td> %4</td> <td> %5</td> <td> %6</td> </tr>" "</table>").arg(histData.min).arg(histData.p10).arg(histData.mean).arg(histData.p90).arg(histData.max).arg(histData.sum); } } return infoText; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::map<std::string, std::vector<std::string> > RimGeoMechResultDefinition::getResultMetaDataForUIFieldSetting() { RimGeoMechCase* gmCase = m_geomCase; if (gmCase && gmCase->geoMechData()) { return gmCase->geoMechData()->femPartResults()->scalarFieldAndComponentNames(m_resultPositionTypeUiField()); } else { return std::map<std::string, std::vector<std::string> >() ; } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) { HistogramData histData; if (m_showResultInfo() || m_showHistogram()) { histData = histogramData(geoMechView); } // Compose text QString infoText; if (m_showCaseInfo()) { infoText = caseInfoText(geoMechView); } if (m_showResultInfo()) { infoText += resultInfoText(histData, geoMechView); } if (!infoText.isEmpty()) { geoMechView->viewer()->setInfoText(infoText); } // Populate histogram if (m_showHistogram()) { RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : nullptr; bool isResultsInfoRelevant = caseData && geoMechView->hasUserRequestedAnimation() && geoMechView->cellResultResultDefinition()->hasResult(); if (isResultsInfoRelevant) { geoMechView->viewer()->showHistogram(true); geoMechView->viewer()->setHistogram(histData.min, histData.max, *histData.histogram); geoMechView->viewer()->setHistogramPercentiles(histData.p10, histData.p90, histData.mean); } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicPasteGeoMechViewsFeature::onActionTriggered(bool isChecked) { caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem()); RimGeoMechCase* geomCase = RicPasteFeatureImpl::findGeoMechCase(destinationObject); assert(geomCase); caf::PdmObjectGroup objectGroup; RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); if (objectGroup.objects.size() == 0) return; std::vector<caf::PdmPointer<RimGeoMechView> > geomViews; objectGroup.objectsByType(&geomViews); RimGeoMechView* lastViewCopy = nullptr; // Add cases to case group for (size_t i = 0; i < geomViews.size(); i++) { RimGeoMechView* rimReservoirView = dynamic_cast<RimGeoMechView*>(geomViews[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); QString nameOfCopy = QString("Copy of ") + rimReservoirView->name(); rimReservoirView->setName(nameOfCopy); geomCase->geoMechViews().push_back(rimReservoirView); rimReservoirView->setGeoMechCase(geomCase); // Resolve references after reservoir view has been inserted into Rim structures // Intersections referencing a well path requires this rimReservoirView->resolveReferencesRecursively(); rimReservoirView->initAfterReadRecursively(); caf::PdmDocument::updateUiIconStateRecursively(rimReservoirView); rimReservoirView->loadDataAndUpdate(); geomCase->intersectionViewCollection()->syncFromExistingIntersections(false); geomCase->updateConnectedEditors(); lastViewCopy = rimReservoirView; } if (lastViewCopy) Riu3DMainWindowTools::selectAsCurrentItem(lastViewCopy); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QString Rim3dOverlayInfoConfig::caseInfoText(RimGeoMechView* geoMechView) { QString infoText; if (geoMechView) { RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : nullptr; RigFemPartCollection* femParts = caseData ? caseData->femParts() : nullptr; if (femParts) { QString caseName = geoMechCase->caseUserDescription(); QString cellCount = QString("%1").arg(femParts->totalElementCount()); QString zScale = QString::number(geoMechView->scaleZ()); infoText = QString( "<p><b>-- %1 --</b><p>" "<b>Cell count:</b> %2 <b>Z-Scale:</b> %3<br>").arg(caseName, cellCount, zScale); } } return infoText; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QString RimWellLogExtractionCurve::wellDate() const { RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value()); RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value()); QStringList timeStepNames; if (eclipseCase) { if (eclipseCase->eclipseCaseData()) { timeStepNames = eclipseCase->timeStepStrings(); } } else if (geomCase) { if (geomCase->geoMechData()) { timeStepNames = geomCase->timeStepStrings(); } } return (m_timeStep >= 0 && m_timeStep < timeStepNames.size()) ? timeStepNames[m_timeStep] : ""; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QString RimWellLogExtractionCurve::createCurveAutoName() { RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value()); RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value()); QStringList generatedCurveName; if (m_addWellNameToCurveName) { if (!wellName().isEmpty()) { generatedCurveName += wellName(); if (m_trajectoryType == SIMULATION_WELL && simulationWellBranches().size() > 1) { generatedCurveName.push_back(" Br" + QString::number(m_branchIndex + 1)); } } } if (m_addCaseNameToCurveName && m_case()) { generatedCurveName.push_back(m_case->caseUserDescription()); } if (m_addPropertyToCurveName && !wellLogChannelName().isEmpty()) { generatedCurveName.push_back(wellLogChannelName()); } if (m_addTimestepToCurveName || m_addDateToCurveName) { size_t maxTimeStep = 0; if (eclipseCase) { if (eclipseCase->eclipseCaseData()) { maxTimeStep = eclipseCase->eclipseCaseData()->results(m_eclipseResultDefinition->porosityModel())->maxTimeStepCount(); } } else if (geomCase) { if (geomCase->geoMechData()) { maxTimeStep = geomCase->geoMechData()->femPartResults()->frameCount(); } } if (m_addDateToCurveName) { QString dateString = wellDate(); if (!dateString.isEmpty()) { generatedCurveName.push_back(dateString); } } if (m_addTimestepToCurveName) { generatedCurveName.push_back(QString("[%1/%2]").arg(m_timeStep()).arg(maxTimeStep)); } } return generatedCurveName.join(", "); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- Rim3dOverlayInfoConfig::HistogramData Rim3dOverlayInfoConfig::histogramData(RimGeoMechView* geoMechView) { HistogramData histData; if (geoMechView) { RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : nullptr; bool isResultsInfoRelevant = caseData && geoMechView->hasUserRequestedAnimation() && geoMechView->cellResultResultDefinition()->hasResult(); if (isResultsInfoRelevant) { RigFemResultAddress resAddress = geoMechView->cellResultResultDefinition()->resultAddress(); if (m_statisticsCellRange == ALL_CELLS) { if (m_statisticsTimeRange == ALL_TIMESTEPS) { caseData->femPartResults()->meanScalarValue(resAddress, &histData.mean); caseData->femPartResults()->minMaxScalarValues(resAddress, &histData.min, &histData.max); caseData->femPartResults()->p10p90ScalarValues(resAddress, &histData.p10, &histData.p90); caseData->femPartResults()->sumScalarValue(resAddress, &histData.sum); histData.histogram = &(caseData->femPartResults()->scalarValuesHistogram(resAddress)); } else if (m_statisticsTimeRange == CURRENT_TIMESTEP) { int timeStepIdx = geoMechView->currentTimeStep(); caseData->femPartResults()->meanScalarValue(resAddress, timeStepIdx, &histData.mean); caseData->femPartResults()->minMaxScalarValues(resAddress, timeStepIdx, &histData.min, &histData.max); caseData->femPartResults()->p10p90ScalarValues(resAddress, timeStepIdx, &histData.p10, &histData.p90); caseData->femPartResults()->sumScalarValue(resAddress, timeStepIdx, &histData.sum); histData.histogram = &(caseData->femPartResults()->scalarValuesHistogram(resAddress, timeStepIdx)); } } else if (m_statisticsCellRange == VISIBLE_CELLS) { this->updateVisCellStatsIfNeeded(); if (m_statisticsTimeRange == ALL_TIMESTEPS) { // TODO: Only valid if we have no dynamic property filter m_visibleCellStatistics->meanCellScalarValues(histData.mean); m_visibleCellStatistics->minMaxCellScalarValues(histData.min, histData.max); m_visibleCellStatistics->p10p90CellScalarValues(histData.p10, histData.p90); m_visibleCellStatistics->sumCellScalarValues(histData.sum); histData.histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram()); } else if (m_statisticsTimeRange == CURRENT_TIMESTEP) { int timeStepIdx = geoMechView->currentTimeStep(); m_visibleCellStatistics->meanCellScalarValues(timeStepIdx, histData.mean); m_visibleCellStatistics->minMaxCellScalarValues(timeStepIdx, histData.min, histData.max); m_visibleCellStatistics->p10p90CellScalarValues(timeStepIdx, histData.p10, histData.p90); m_visibleCellStatistics->sumCellScalarValues(timeStepIdx, histData.sum); histData.histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram(timeStepIdx)); } } } } return histData; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) { if (showInfoText()) { QString infoText; RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : NULL; RigFemPartCollection* femParts = caseData ? caseData->femParts() : NULL; if (femParts) { QString caseName = geoMechCase->caseUserDescription(); QString cellCount = QString("%1").arg(femParts->totalElementCount()); QString zScale = QString::number(geoMechView->scaleZ()); infoText = QString( "<p><b><center>-- %1 --</center></b><p>" "<b>Cell count:</b> %2 <b>Z-Scale:</b> %3<br>").arg(caseName, cellCount, zScale); if (geoMechView->hasUserRequestedAnimation() && geoMechView->cellResult()->hasResult()) { QString resultPos; QString fieldName = geoMechView->cellResult()->resultFieldUiName(); QString compName = geoMechView->cellResult()->resultComponentUiName(); if (!fieldName.isEmpty()) { switch (geoMechView->cellResult()->resultPositionType()) { case RIG_NODAL: resultPos = "Nodal"; break; case RIG_ELEMENT_NODAL: resultPos = "Element nodal"; break; case RIG_INTEGRATION_POINT: resultPos = "Integration point"; break; default: break; } infoText += QString( "<b>Cell result:</b> %1, %2, %3").arg(resultPos).arg(fieldName).arg(compName); double min = 0, max = 0; double p10 = 0, p90 = 0; double mean = 0; RigFemResultAddress resAddress = geoMechView->cellResult()->resultAddress(); caseData->femPartResults()->meanScalarValue(resAddress, &mean); caseData->femPartResults()->minMaxScalarValues(resAddress,&min, &max); // ToDo: Implement statistics for geomech data caseData->femPartResults()->p10p90ScalarValues(resAddress, &p10, &p90); infoText += QString("<table border=0 cellspacing=5 ><tr><td>Min</td><td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> </tr>" "<tr><td>%1</td><td> %2</td><td> %3</td><td> %4</td><td> %5 </td></tr></table>").arg(min).arg(p10).arg(mean).arg(p90).arg(max); } else { infoText += QString("<br>"); } int currentTimeStep = geoMechView->currentTimeStep(); QString stepName = QString::fromStdString(caseData->femPartResults()->stepNames()[currentTimeStep]); infoText += QString("<b>Time Step:</b> %1 <b>Time:</b> %2").arg(currentTimeStep).arg(stepName); } } geoMechView->viewer()->setInfoText(infoText); } if (showHistogram()) { if (geoMechView->hasUserRequestedAnimation() && geoMechView->cellResult()->hasResult()) { geoMechView->viewer()->showHistogram(true); // ToDo: Implement statistics for geomech data RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : NULL; if (caseData) { double min = 0, max = 0; double p10 = 0, p90 = 0; double mean = 0; RigFemResultAddress resAddress = geoMechView->cellResult()->resultAddress(); caseData->femPartResults()->meanScalarValue(resAddress, &mean); caseData->femPartResults()->minMaxScalarValues(resAddress, &min, &max); caseData->femPartResults()->p10p90ScalarValues(resAddress, &p10, &p90); geoMechView->viewer()->setHistogram(min, max, caseData->femPartResults()->scalarValuesHistogram(resAddress)); geoMechView->viewer()->setHistogramPercentiles(p10, p90, mean); } } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) { RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : NULL; bool isResultsInfoRelevant = caseData && geoMechView->hasUserRequestedAnimation() && geoMechView->cellResultResultDefinition()->hasResult(); // Retreive result stats if needed double min = HUGE_VAL, max = HUGE_VAL; double p10 = HUGE_VAL, p90 = HUGE_VAL; double mean = HUGE_VAL; double sum = 0.0; const std::vector<size_t>* histogram = NULL; if (showResultInfo() || showHistogram()) { if (isResultsInfoRelevant) { RigFemResultAddress resAddress = geoMechView->cellResultResultDefinition()->resultAddress(); if (m_statisticsCellRange == ALL_CELLS) { if (m_statisticsTimeRange == ALL_TIMESTEPS) { caseData->femPartResults()->meanScalarValue(resAddress, &mean); caseData->femPartResults()->minMaxScalarValues(resAddress, &min, &max); caseData->femPartResults()->p10p90ScalarValues(resAddress, &p10, &p90); caseData->femPartResults()->sumScalarValue(resAddress, &sum); histogram = &(caseData->femPartResults()->scalarValuesHistogram(resAddress)); } else if (m_statisticsTimeRange == CURRENT_TIMESTEP) { int timeStepIdx = geoMechView->currentTimeStep(); caseData->femPartResults()->meanScalarValue(resAddress, timeStepIdx, &mean); caseData->femPartResults()->minMaxScalarValues(resAddress, timeStepIdx, &min, &max); caseData->femPartResults()->p10p90ScalarValues(resAddress, timeStepIdx, &p10, &p90); caseData->femPartResults()->sumScalarValue(resAddress, timeStepIdx, &sum); histogram = &(caseData->femPartResults()->scalarValuesHistogram(resAddress, timeStepIdx)); } } else if (m_statisticsCellRange == VISIBLE_CELLS) { this->updateVisCellStatsIfNeeded(); if (m_statisticsTimeRange == ALL_TIMESTEPS) { // TODO: Only valid if we have no dynamic property filter m_visibleCellStatistics->meanCellScalarValues(mean); m_visibleCellStatistics->minMaxCellScalarValues(min, max); m_visibleCellStatistics->p10p90CellScalarValues(p10, p90); m_visibleCellStatistics->sumCellScalarValues(sum); histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram()); } else if (m_statisticsTimeRange == CURRENT_TIMESTEP) { int timeStepIdx = geoMechView->currentTimeStep(); m_visibleCellStatistics->meanCellScalarValues(timeStepIdx, mean); m_visibleCellStatistics->minMaxCellScalarValues(timeStepIdx, min, max); m_visibleCellStatistics->p10p90CellScalarValues(timeStepIdx, p10, p90); m_visibleCellStatistics->sumCellScalarValues(timeStepIdx, sum); histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram(timeStepIdx)); } } } } // Compose text QString infoText; if (showCaseInfo()) { RigFemPartCollection* femParts = caseData ? caseData->femParts() : NULL; if (femParts) { QString caseName = geoMechCase->caseUserDescription(); QString cellCount = QString("%1").arg(femParts->totalElementCount()); QString zScale = QString::number(geoMechView->scaleZ()); infoText = QString( "<p><b><center>-- %1 --</center></b><p>" "<b>Cell count:</b> %2 <b>Z-Scale:</b> %3<br>").arg(caseName, cellCount, zScale); } } if (showResultInfo()) { if (isResultsInfoRelevant) { { QString resultPos; QString fieldName = geoMechView->cellResultResultDefinition()->resultFieldUiName(); QString compName = geoMechView->cellResultResultDefinition()->resultComponentUiName(); switch (geoMechView->cellResultResultDefinition()->resultPositionType()) { case RIG_NODAL: resultPos = "Nodal"; break; case RIG_ELEMENT_NODAL: resultPos = "Element nodal"; break; case RIG_INTEGRATION_POINT: resultPos = "Integration point"; break; default: break; } infoText += QString("<b>Cell result:</b> %1, %2, %3").arg(resultPos).arg(fieldName).arg(compName); } { infoText += QString("<br><b>Statistics:</b> ") + m_statisticsTimeRange().uiText() + " and " + m_statisticsCellRange().uiText(); infoText += QString("<table border=0 cellspacing=5 >" "<tr> <td>Min</td> <td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> <td>Sum</td> </tr>" "<tr> <td>%1</td> <td> %2</td> <td> %3</td> <td> %4</td> <td> %5</td> <td> %6</td> </tr>" "</table>").arg(min).arg(p10).arg(mean).arg(p90).arg(max).arg(sum); } } } if (!infoText.isEmpty()) { geoMechView->viewer()->setInfoText(infoText); } // Populate histogram if (showHistogram()) { if (isResultsInfoRelevant) { geoMechView->viewer()->showHistogram(true); geoMechView->viewer()->setHistogram(min, max, *histogram); geoMechView->viewer()->setHistogramPercentiles(p10, p90, mean); } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QString Rim3dWellLogExtractionCurve::createCurveAutoName() const { RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value()); RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value()); QStringList generatedCurveName; if (m_nameConfig->addWellName()) { RimWellPath* wellPath; this->firstAncestorOrThisOfTypeAsserted(wellPath); if (!wellPath->name().isEmpty()) { generatedCurveName += wellPath->name(); } } if (m_nameConfig->addCaseName() && m_case()) { generatedCurveName.push_back(m_case->caseUserDescription()); } if (m_nameConfig->addProperty() && !resultPropertyString().isEmpty()) { generatedCurveName.push_back(resultPropertyString()); } if (m_nameConfig->addTimeStep() || m_nameConfig->addDate()) { size_t maxTimeStep = 0; if (eclipseCase) { RigEclipseCaseData* data = eclipseCase->eclipseCaseData(); if (data) { maxTimeStep = data->results(m_eclipseResultDefinition->porosityModel())->maxTimeStepCount(); } } else if (geomCase) { RigGeoMechCaseData* data = geomCase->geoMechData(); if (data) { maxTimeStep = data->femPartResults()->frameCount(); } } if (m_nameConfig->addDate()) { QString dateString = wellDate(); if (!dateString.isEmpty()) { generatedCurveName.push_back(dateString); } } if (m_nameConfig->addTimeStep()) { generatedCurveName.push_back(QString("[%1/%2]").arg(m_timeStep()).arg(maxTimeStep)); } } return generatedCurveName.join(", "); }