//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimGeoMechCase::updateFormationNamesData() { RigGeoMechCaseData* rigCaseData = geoMechData(); if(rigCaseData && rigCaseData->femPartResults()) { if(activeFormationNames()) { rigCaseData->femPartResults()->setActiveFormationNames(activeFormationNames()->formationNamesData()); } else { rigCaseData->femPartResults()->setActiveFormationNames(nullptr); } std::vector<Rim3dView*> views = this->views(); for(Rim3dView* view : views) { RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(view); if ( geomView && geomView->isUsingFormationNames() ) { if ( !activeFormationNames() ) { if ( geomView->cellResult()->resultPositionType() == RIG_FORMATION_NAMES ) { geomView->cellResult()->setResultAddress(RigFemResultAddress(RIG_FORMATION_NAMES, "", "")); geomView->cellResult()->updateConnectedEditors(); } RimGeoMechPropertyFilterCollection* eclFilColl = geomView->geoMechPropertyFilterCollection(); for ( RimGeoMechPropertyFilter* propFilter : eclFilColl->propertyFilters ) { if ( propFilter->resultDefinition()->resultPositionType() == RIG_FORMATION_NAMES ) { propFilter->resultDefinition()->setResultAddress(RigFemResultAddress(RIG_FORMATION_NAMES, "", "")); } } } RimGeoMechPropertyFilterCollection* eclFilColl = geomView->geoMechPropertyFilterCollection(); for ( RimGeoMechPropertyFilter* propFilter : eclFilColl->propertyFilters ) { if ( propFilter->resultDefinition->resultPositionType() == RIG_FORMATION_NAMES ) { propFilter->setToDefaultValues(); propFilter->updateConnectedEditors(); } } geomView->cellResult()->updateConnectedEditors(); view->scheduleGeometryRegen(PROPERTY_FILTERED); view->scheduleCreateDisplayModelAndRedraw(); geomView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimGeoMechView::updateLegends() { if (m_viewer) { m_viewer->removeAllColorLegends(); } if (!m_geomechCase || !m_viewer || !m_geomechCase->geoMechData() || !this->isTimeStepDependentDataVisible() || !(cellResult()->resultAddress().isValid()) ) { return; } double localMin, localMax; double localPosClosestToZero, localNegClosestToZero; double globalMin, globalMax; double globalPosClosestToZero, globalNegClosestToZero; RigGeoMechCaseData* gmCase = m_geomechCase->geoMechData(); CVF_ASSERT(gmCase); RigFemResultAddress resVarAddress = cellResult()->resultAddress(); gmCase->femPartResults()->minMaxScalarValues(resVarAddress, m_currentTimeStep, &localMin, &localMax); gmCase->femPartResults()->posNegClosestToZero(resVarAddress, m_currentTimeStep, &localPosClosestToZero, &localNegClosestToZero); gmCase->femPartResults()->minMaxScalarValues(resVarAddress, &globalMin, &globalMax); gmCase->femPartResults()->posNegClosestToZero(resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero); cellResult()->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); cellResult()->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); cvf::String legendTitle = cvfqt::Utils::toString( caf::AppEnum<RigFemResultPosEnum>(cellResult->resultPositionType()).uiText() + "\n" + cellResult->resultFieldUiName()); if (!cellResult->resultComponentUiName().isEmpty()) { legendTitle += ", " + cvfqt::Utils::toString(cellResult->resultComponentUiName()); } if (cellResult->resultFieldName() == "SE" || cellResult->resultFieldName() == "ST" || cellResult->resultFieldName() == "POR-Bar") { legendTitle += " [Bar]"; } cellResult()->legendConfig->legend()->setTitle(legendTitle); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimGeoMechCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { if(changedField == &activeFormationNames) { updateFormationNamesData(); } if (changedField == &m_cohesion || changedField == &m_frictionAngleDeg) { RigGeoMechCaseData* rigCaseData = geoMechData(); if ( rigCaseData && rigCaseData->femPartResults() ) { rigCaseData->femPartResults()->setCalculationParameters(m_cohesion(), cvf::Math::toRadians(m_frictionAngleDeg())); } std::vector<Rim3dView*> views = this->views(); for ( Rim3dView* view : views ) { if ( view ) // Todo: only those using the variable actively { view->scheduleCreateDisplayModelAndRedraw(); } } } else if (changedField == &m_reloadElementPropertyFileCommand) { m_reloadElementPropertyFileCommand = false; reloadSelectedElementPropertyFiles(); updateConnectedEditors(); } else if (changedField == &m_closeElementPropertyFileCommand) { m_closeElementPropertyFileCommand = false; closeSelectedElementPropertyFiles(); updateConnectedEditors(); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr(RivGeoMechPartMgrCache::Key pMgrKey) { if (!m_partMgrCache->isNeedingRegeneration(pMgrKey)) { return m_partMgrCache->partMgr(pMgrKey); } RivGeoMechPartMgr* partMgrToUpdate = m_partMgrCache->partMgr(pMgrKey); RigGeoMechCaseData* caseData = m_geomechView->geoMechCase()->geoMechData(); int partCount = caseData->femParts()->partCount(); if (partMgrToUpdate->initializedFemPartCount() != partCount) { partMgrToUpdate->clearAndSetReservoir(caseData); } for (int femPartIdx = 0; femPartIdx < partCount; ++femPartIdx) { cvf::ref<cvf::UByteArray> elmVisibility = partMgrToUpdate->cellVisibility(femPartIdx); partMgrToUpdate->setTransform(m_geomechView->scaleTransform()); if (pMgrKey.geometryType() == RANGE_FILTERED) { cvf::CellRangeFilter cellRangeFilter; m_geomechView->rangeFilterCollection()->compoundCellRangeFilter(&cellRangeFilter, femPartIdx); RivFemElmVisibilityCalculator::computeRangeVisibility( elmVisibility.p(), caseData->femParts()->part(femPartIdx), cellRangeFilter); } else if (pMgrKey.geometryType() == PROPERTY_FILTERED) { RivGeoMechPartMgr* rangefiltered = NULL; if (m_geomechView->rangeFilterCollection()->hasActiveFilters()) { rangefiltered = getUpdatedPartMgr(RivGeoMechPartMgrCache::Key(RANGE_FILTERED, -1)); } else { rangefiltered = getUpdatedPartMgr(RivGeoMechPartMgrCache::Key(ALL_CELLS, -1)); } cvf::ref<cvf::UByteArray> rangeFiltVisibility = rangefiltered->cellVisibility(femPartIdx); RivFemElmVisibilityCalculator::computePropertyVisibility(elmVisibility.p(), caseData->femParts()->part(femPartIdx), pMgrKey.frameIndex(), rangeFiltVisibility.p(), m_geomechView->geoMechPropertyFilterCollection() ); } else if (pMgrKey.geometryType() == OVERRIDDEN_CELL_VISIBILITY) { RivFemElmVisibilityCalculator::computeOverriddenCellVisibility(elmVisibility.p(), caseData->femParts()->part(femPartIdx), m_geomechView->viewController()); } else if (pMgrKey.geometryType() == ALL_CELLS) { RivFemElmVisibilityCalculator::computeAllVisible(elmVisibility.p(), caseData->femParts()->part(femPartIdx)); } else { CVF_ASSERT(false); // Unsupported CellSet Enum } partMgrToUpdate->setCellVisibility(femPartIdx, elmVisibility.p()); } m_partMgrCache->setGenerationFinished(pMgrKey); return partMgrToUpdate; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* cellVisibility, const RigFemPart* grid, int timeStepIndex, const cvf::UByteArray* rangeFilterVisibility, RimGeoMechPropertyFilterCollection* propFilterColl) { CVF_ASSERT(cellVisibility != NULL); CVF_ASSERT(rangeFilterVisibility != NULL); CVF_ASSERT(propFilterColl != NULL); CVF_ASSERT(grid->elementCount() > 0); CVF_ASSERT(rangeFilterVisibility->size() == static_cast<size_t>(grid->elementCount())); // Copy if not equal if (cellVisibility != rangeFilterVisibility ) (*cellVisibility) = *rangeFilterVisibility; const int elementCount = grid->elementCount(); if (propFilterColl->hasActiveFilters()) { for (size_t i = 0; i < propFilterColl->propertyFilters().size(); i++) { RimGeoMechPropertyFilter* propertyFilter = propFilterColl->propertyFilters()[i]; if (propertyFilter->isActive() && propertyFilter->resultDefinition->hasResult()) { const double lowerBound = propertyFilter->lowerBound(); const double upperBound = propertyFilter->upperBound(); RigFemResultAddress resVarAddress = propertyFilter->resultDefinition->resultAddress(); size_t adjustedTimeStepIndex = timeStepIndex; const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode(); RigGeoMechCaseData* caseData = propFilterColl->reservoirView()->geoMechCase()->geoMechData(); const std::vector<float>& resVals = caseData->femPartResults()->resultValues(resVarAddress, grid->elementPartId(), timeStepIndex); #pragma omp parallel for schedule(dynamic) for (int cellIndex = 0; cellIndex < elementCount; cellIndex++) { if ( (*cellVisibility)[cellIndex] ) { RigElementType eType = grid->elementType(cellIndex); int elmNodeCount = RigFemTypes::elmentNodeCount(eType); const int* elmNodeIndices = grid->connectivities(cellIndex); for(int enIdx = 0; enIdx < elmNodeCount; ++enIdx) { size_t resultValueIndex = cvf::UNDEFINED_SIZE_T; if (resVarAddress.resultPosType == RIG_NODAL) { resultValueIndex = elmNodeIndices[enIdx]; } else { resultValueIndex = grid->elementNodeResultIdx(cellIndex, enIdx); } double scalarValue = resVals[resultValueIndex]; if (lowerBound <= scalarValue && scalarValue <= upperBound) { if (filterType == RimCellFilter::EXCLUDE) { (*cellVisibility)[cellIndex] = false; } } else { if (filterType == RimCellFilter::INCLUDE) { (*cellVisibility)[cellIndex] = false; } } } } } } } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RivCrossSectionPartMgr::updateCellResultColor(size_t timeStepIndex) { if (m_crossSectionGenerator.isNull()) return; if (!m_crossSectionGenerator->isAnyGeometryPresent()) return; RimEclipseView* eclipseView; m_rimCrossSection->firstAnchestorOrThisOfType(eclipseView); if (eclipseView) { RimEclipseCellColors* cellResultColors = eclipseView->cellResult(); CVF_ASSERT(cellResultColors); RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultColors->porosityModel()); RigCaseData* eclipseCase = eclipseView->eclipseCase()->reservoirData(); // CrossSections if (m_crossSectionFaces.notNull()) { if (cellResultColors->isTernarySaturationSelected()) { RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), timeStepIndex); texturer.createTextureCoords(m_crossSectionFacesTextureCoords.p(), m_crossSectionGenerator->triangleToCellIndex()); const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_crossSectionFaces.p(), m_crossSectionFacesTextureCoords.p(), mapper, 1.0, caf::FC_NONE, eclipseView->isLightingDisabled()); } else { CVF_ASSERT(m_crossSectionGenerator.notNull()); const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); cvf::ref<RigResultAccessor> resultAccessor; if (RimDefines::isPerCellFaceResult(cellResultColors->resultVariable())) { resultAccessor = new RigHugeValResultAccessor; } else { resultAccessor = RigResultAccessorFactory::createResultAccessor(cellResultColors->reservoirView()->eclipseCase()->reservoirData(), 0, timeStepIndex, cellResultColors); } RivCrossSectionPartMgr::calculateEclipseTextureCoordinates(m_crossSectionFacesTextureCoords.p(), m_crossSectionGenerator->triangleToCellIndex(), resultAccessor.p(), mapper); RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(), m_crossSectionFacesTextureCoords.p(), mapper, 1.0, caf::FC_NONE, eclipseView->isLightingDisabled()); } } } RimGeoMechView* geoView; m_rimCrossSection->firstAnchestorOrThisOfType(geoView); if (geoView) { RimGeoMechCellColors* cellResultColors = geoView->cellResult(); RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData(); if (!caseData) return; RigFemResultAddress resVarAddress = cellResultColors->resultAddress(); // Do a "Hack" to show elm nodal and not nodal POR results if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL; const std::vector<RivVertexWeights> &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights(); const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL); RigFemPart* femPart = caseData->femParts()->part(0); const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); RivCrossSectionPartMgr::calculateGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(), vertexWeights, resultValues, isElementNodalResult, femPart, mapper); RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(), m_crossSectionFacesTextureCoords.p(), mapper, 1.0, caf::FC_NONE, geoView->isLightingDisabled()); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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); } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCellColors* cellResultColors) { CVF_ASSERT(cellResultColors); cvf::ref<cvf::Color3ubArray> surfaceFacesColorArray; // Outer surface if (m_surfaceFaces.notNull()) { const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData(); if (!caseData) return; RigFemResultAddress resVarAddress = cellResultColors->resultAddress(); // Do a "Hack" to show elm nodal and not nodal POR results if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL; const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, m_gridIdx, (int)timeStepIndex); const std::vector<size_t>* vxToResultMapping = NULL; if (resVarAddress.resultPosType == RIG_NODAL) { vxToResultMapping = &(m_surfaceGenerator.quadVerticesToNodeIdxMapping()); } else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL || resVarAddress.resultPosType == RIG_INTEGRATION_POINT) { vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmNodeIdx()); } m_surfaceFacesTextureCoords->resize(vxToResultMapping->size()); if (resultValues.size() == 0) { m_surfaceFacesTextureCoords->setAll(cvf::Vec2f(0.0, 1.0f)); } else { cvf::Vec2f* rawPtr = m_surfaceFacesTextureCoords->ptr(); int vxCount = static_cast<int>(vxToResultMapping->size()); #pragma omp parallel for schedule(dynamic) for (int quadStartIdx = 0; quadStartIdx < vxCount; quadStartIdx += 4) { float resultValue1 = resultValues[(*vxToResultMapping)[quadStartIdx]]; float resultValue2 = resultValues[(*vxToResultMapping)[quadStartIdx + 1]]; float resultValue3 = resultValues[(*vxToResultMapping)[quadStartIdx + 2]]; float resultValue4 = resultValues[(*vxToResultMapping)[quadStartIdx + 3]]; if ( resultValue1 == HUGE_VAL || resultValue1 != resultValue1 // a != a is true for NAN's || resultValue2 == HUGE_VAL || resultValue2 != resultValue2 || resultValue3 == HUGE_VAL || resultValue3 != resultValue3 || resultValue4 == HUGE_VAL || resultValue4 != resultValue4) { rawPtr[quadStartIdx][1] = 1.0f; rawPtr[quadStartIdx + 1][1] = 1.0f; rawPtr[quadStartIdx + 2][1] = 1.0f; rawPtr[quadStartIdx + 3][1] = 1.0f; } else { rawPtr[quadStartIdx] = mapper->mapToTextureCoord(resultValue1); rawPtr[quadStartIdx + 1] = mapper->mapToTextureCoord(resultValue2); rawPtr[quadStartIdx + 2] = mapper->mapToTextureCoord(resultValue3); rawPtr[quadStartIdx + 3] = mapper->mapToTextureCoord(resultValue4); } } } RimView* view = NULL; cellResultColors->firstAnchestorOrThisOfType(view); CVF_ASSERT(view); RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper, m_opacityLevel, caf::FC_NONE, view->isLightingDisabled()); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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(", "); }