Пример #1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
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;
}
Пример #2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
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;
}
Пример #3
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
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());
    }
}
Пример #4
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
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);
            }
        }
    }
}
Пример #5
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
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);
        }
    }
}