//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
const cvf::StructGridInterface* RimCellRangeFilterCollection::gridByIndex(int gridIndex) const
{
    RigMainGrid* mnGrid = mainGrid();
    RigFemPartCollection* femPartColl = this->femPartColl();

    if (mnGrid)
    {
        RigGridBase* grid = NULL;

        grid = mnGrid->gridByIndex(gridIndex);

        CVF_ASSERT(grid);

        return grid;
    }
    else if (femPartColl)
    {
        if (gridIndex < femPartColl->partCount())
            return femPartColl->part(gridIndex)->structGrid();
        else 
            return NULL;
    }
    
    return NULL;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
int RimCellRangeFilterCollection::gridCount() const
{
    RigMainGrid* mnGrid = mainGrid();
    RigFemPartCollection* femPartColl = this->femPartColl();

    if (mnGrid)
    {
        return (int)mnGrid->gridCount();
    }
    else if (femPartColl)
    {
        return femPartColl->partCount();
    }

    return 0;
}
Пример #3
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;
}
Пример #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);
        }
    }
}