Example #1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::setPropertiesFromView(Rim3dView* view)
{
    m_case = view ? view->ownerCase() : nullptr;

    RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value());
    RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
    m_eclipseResultDefinition->setEclipseCase(eclipseCase);
    m_geomResultDefinition->setGeoMechCase(geomCase);

    RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(view);
    if (eclipseView)
    {
        m_eclipseResultDefinition->simpleCopy(eclipseView->cellResult());

        m_timeStep = eclipseView->currentTimeStep();
    }

    RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>(view);
    if (geoMechView)
    {
        m_geomResultDefinition->setResultAddress(geoMechView->cellResultResultDefinition()->resultAddress());
        m_timeStep = geoMechView->currentTimeStep();
    }

    clearGeneratedSimWellPaths();
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimGeoMechPropertyFilterCollection::updateIconState()
{
    bool activeIcon = true;

    RimGeoMechView* view = NULL;
    this->firstAncestorOrThisOfType(view);
    RimViewController* viewController = view->viewController();
    if (viewController && ( viewController->isPropertyFilterOveridden() 
                            || viewController->isVisibleCellsOveridden()))
    {
        activeIcon = false;
    }

    if (!isActive)
    {
        activeIcon = false;
    }

    updateUiIconFromState(activeIcon);

    for (size_t i = 0; i < propertyFilters.size(); i++)
    {
        RimGeoMechPropertyFilter* propFilter = propertyFilters[i];
        propFilter->updateActiveState();
        propFilter->updateIconState();
    }
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void Rim3dOverlayInfoConfig::updateVisCellStatsIfNeeded()
{
    RimEclipseView * eclipseView = dynamic_cast<RimEclipseView*>(m_viewDef.p());
    RimGeoMechView * geoMechView = dynamic_cast<RimGeoMechView*>(m_viewDef.p());

    if (!m_isVisCellStatUpToDate)
    {
        cvf::ref<RigStatisticsCalculator> calc;
        if (geoMechView)
        {
            RigFemResultAddress resAddress = geoMechView->cellResultResultDefinition()->resultAddress();
            calc = new RigFemNativeVisibleCellsStatCalc(geoMechView->geoMechCase()->geoMechData(),
                                                        resAddress,
                                                        geoMechView->currentTotalCellVisibility().p());
          
        }
        else if (eclipseView)
        {
           size_t scalarIndex = eclipseView->cellResult()->scalarResultIndex();
           calc = new RigEclipseNativeVisibleCellsStatCalc(eclipseView->currentGridCellResults()->cellResults(),
                                                           scalarIndex,
                                                           eclipseView->currentTotalCellVisibility().p());
        }

        m_visibleCellStatistics = new RigStatisticsDataCache(calc.p());
        m_isVisCellStatUpToDate = true;
    }
}
Example #4
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
RimGeoMechCase* RicPasteFeatureImpl::findGeoMechCase(caf::PdmObjectHandle* objectHandle)
{
    RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(objectHandle);
    if (!geomCase)
    {
        RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(objectHandle);
        if (geomView) geomCase = geomView->geoMechCase();
    }

    return geomCase;
}
Example #5
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
RimGeoMechView* RimGeoMechCase::createAndAddReservoirView()
{
    RimGeoMechView* gmv = new RimGeoMechView();
    size_t i = geoMechViews().size();
    gmv->name = QString("View %1").arg(i + 1);
    
    gmv->setGeoMechCase(this);

    geoMechViews.push_back(gmv);
    return gmv;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
RigFemPartCollection* RimCellRangeFilterCollection::femPartColl() const
{
    RimGeoMechView* geoView = dynamic_cast<RimGeoMechView*>(baseView());
    if (geoView &&
        geoView->geoMechCase() &&
        geoView->geoMechCase()->geoMechData() )
    {
        return geoView->geoMechCase()->geoMechData()->femParts();
    }

    return NULL;
}
Example #7
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
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();
            }
        }
    }
}
Example #8
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimGeoMechCase::initAfterRead()
{
    size_t j;
    for (j = 0; j < geoMechViews().size(); j++)
    {
        RimGeoMechView* riv = geoMechViews()[j];
        CVF_ASSERT(riv);

        riv->setGeoMechCase(this);
    }

}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicGeoMechPropertyFilterFeatureImpl::setDefaults(RimGeoMechPropertyFilter* propertyFilter)
{
    CVF_ASSERT(propertyFilter);

    RimGeoMechPropertyFilterCollection* propertyFilterCollection = propertyFilter->parentContainer();
    CVF_ASSERT(propertyFilterCollection);

    RimGeoMechView* reservoirView = propertyFilterCollection->reservoirView();
    CVF_ASSERT(reservoirView);

    propertyFilter->resultDefinition->setGeoMechCase(reservoirView->geoMechCase());
    propertyFilter->resultDefinition->setResultAddress(reservoirView->cellResult()->resultAddress());
    propertyFilter->resultDefinition->loadResult();
    propertyFilter->setToDefaultValues();
    propertyFilter->updateFilterName();
}
Example #10
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
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->name = 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);
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicGeoMechPropertyFilterNewInViewFeature::onActionTriggered(bool isChecked)
{
    Rim3dView* view = RiaApplication::instance()->activeReservoirView();
    if (!view) return;
    RimGeoMechView* eclView = dynamic_cast<RimGeoMechView*>(view);
    if (!eclView) return;

    RicGeoMechPropertyFilterNewExec* filterExec = new RicGeoMechPropertyFilterNewExec(eclView->geoMechPropertyFilterCollection());
    caf::CmdExecCommandManager::instance()->processExecuteCommand(filterExec);
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool RicGeoMechPropertyFilterNewInViewFeature::isCommandEnabled()
{
    Rim3dView* view = RiaApplication::instance()->activeReservoirView();
    if (!view) return false;
    
    RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>(view);
    if (!geoMechView) return false;

    RimGeoMechCellColors* cellColors = geoMechView->cellResult().p();
    if (!cellColors) return false;

    RimGeoMechPropertyFilterCollection* filterCollection = geoMechView->geoMechPropertyFilterCollection();
    if (filterCollection)
    {
        return RicGeoMechPropertyFilterFeatureImpl::isPropertyFilterCommandAvailable(filterCollection);
    }

    return false;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
cvf::ref<RivCrossSectionHexGridIntf> RivCrossSectionPartMgr::createHexGridInterface()
{

    RimEclipseView* eclipseView;
    m_rimCrossSection->firstAnchestorOrThisOfType(eclipseView);
    if (eclipseView)
    {
        RigMainGrid* grid = NULL;
        grid = eclipseView->eclipseCase()->reservoirData()->mainGrid();
        return new RivEclipseCrossSectionGrid(grid, eclipseView->currentActiveCellInfo(), m_rimCrossSection->showInactiveCells());
    }

    RimGeoMechView* geoView;
    m_rimCrossSection->firstAnchestorOrThisOfType(geoView);
    if (geoView)
    {
        RigFemPart* femPart = geoView->geoMechCase()->geoMechData()->femParts()->part(0);
        return new RivFemCrossSectionGrid(femPart);
    }

    return NULL;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
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());
    }
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiuSelectionChangedHandler::updateResultInfo(const RiuSelectionItem* itemAdded) const
{
    QString resultInfo;
    QString pickInfo;

    RiuSelectionItem* selItem = const_cast<RiuSelectionItem*>(itemAdded);
    if (selItem != nullptr)
    {
        Rim2dIntersectionView* intersectionView = nullptr;

        if (selItem->type() == RiuSelectionItem::INTERSECTION_SELECTION_OBJECT)
        {
            const Riu2dIntersectionSelectionItem* wrapperSelItem = dynamic_cast<Riu2dIntersectionSelectionItem*>(selItem);
            if (wrapperSelItem)
            {
                intersectionView = wrapperSelItem->view();
                if (wrapperSelItem->eclipseSelectionItem())
                {
                    selItem = wrapperSelItem->eclipseSelectionItem();
                }
                else if (wrapperSelItem->geoMechSelectionItem())
                {
                    selItem = wrapperSelItem->geoMechSelectionItem();
                }
            }
        }

        if (selItem->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT)
        {
            const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast<const RiuEclipseSelectionItem*>(selItem);

            RimEclipseView* eclipseView = eclipseSelectionItem->m_view.p();

            RiuResultTextBuilder textBuilder(eclipseView, eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_gridLocalCellIndex, eclipseView->currentTimeStep());
            textBuilder.setFace(eclipseSelectionItem->m_face);
            textBuilder.setNncIndex(eclipseSelectionItem->m_nncIndex);
            textBuilder.setIntersectionPointInDisplay(eclipseSelectionItem->m_localIntersectionPointInDisplay);
            textBuilder.set2dIntersectionView(intersectionView);

            resultInfo = textBuilder.mainResultText();

            pickInfo = textBuilder.geometrySelectionText(", ");
        }
        else if (selItem->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT)
        {
            const RiuGeoMechSelectionItem* geomSelectionItem = static_cast<const RiuGeoMechSelectionItem*>(selItem);

            RimGeoMechView* geomView = geomSelectionItem->m_view.p();
            RiuFemResultTextBuilder textBuilder(geomView, (int)geomSelectionItem->m_gridIndex, (int)geomSelectionItem->m_cellIndex, geomView->currentTimeStep());
            textBuilder.setIntersectionPointInDisplay(geomSelectionItem->m_localIntersectionPointInDisplay);
            textBuilder.setFace(geomSelectionItem->m_elementFace);
            textBuilder.set2dIntersectionView(intersectionView);
            if (geomSelectionItem->m_hasIntersectionTriangle) textBuilder.setIntersectionTriangle(geomSelectionItem->m_intersectionTriangle);

            resultInfo = textBuilder.mainResultText();

            pickInfo = textBuilder.geometrySelectionText(", ");
        }
    }

    RiuMainWindow* mainWnd = RiuMainWindow::instance();
    mainWnd->statusBar()->showMessage(pickInfo);
    mainWnd->setResultInfo(resultInfo);
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiuSelectionChangedHandler::addCurveFromSelectionItem(const RiuGeoMechSelectionItem* geomSelectionItem) const
{
    RimGeoMechView* geoMechView = geomSelectionItem->m_view.p();

    if (geoMechView &&
        geoMechView->cellResultResultDefinition() &&
        geoMechView->cellResultResultDefinition()->hasResult() &&
        geoMechView->geoMechCase() &&
        geoMechView->geoMechCase()->geoMechData())
    {
        std::unique_ptr<RiuFemTimeHistoryResultAccessor> timeHistResultAccessor;

        cvf::Vec3d intersectionPointInDomain = geoMechView->displayCoordTransform()->translateToDomainCoord(geomSelectionItem->m_localIntersectionPointInDisplay);

        if ( geomSelectionItem->m_hasIntersectionTriangle )
        {
            timeHistResultAccessor = std::unique_ptr<RiuFemTimeHistoryResultAccessor>(
                new RiuFemTimeHistoryResultAccessor(geoMechView->geoMechCase()->geoMechData(),
                                                    geoMechView->cellResultResultDefinition()->resultAddress(),
                                                    geomSelectionItem->m_gridIndex,
                                                    static_cast<int>(geomSelectionItem->m_cellIndex),
                                                    geomSelectionItem->m_elementFace,
                                                    intersectionPointInDomain,
                                                    geomSelectionItem->m_intersectionTriangle));
        }
        else
        {
            timeHistResultAccessor = std::unique_ptr<RiuFemTimeHistoryResultAccessor>(
                new RiuFemTimeHistoryResultAccessor(geoMechView->geoMechCase()->geoMechData(),
                                                    geoMechView->cellResultResultDefinition()->resultAddress(),
                                                    geomSelectionItem->m_gridIndex,
                                                    static_cast<int>(geomSelectionItem->m_cellIndex),
                                                    geomSelectionItem->m_elementFace,
                                                    intersectionPointInDomain));
        }

        QString curveName;
        curveName.append(geoMechView->geoMechCase()->caseUserDescription() + ", ");

        caf::AppEnum<RigFemResultPosEnum> resPosAppEnum = geoMechView->cellResultResultDefinition()->resultPositionType();
        curveName.append(resPosAppEnum.uiText() + ", ");
        curveName.append(geoMechView->cellResultResultDefinition()->resultFieldUiName()+ ", ") ;
        curveName.append(geoMechView->cellResultResultDefinition()->resultComponentUiName() + " ");
        
        if ( resPosAppEnum == RIG_ELEMENT_NODAL_FACE )
        {
            if ( geomSelectionItem->m_elementFace >= 0 )
            {
                curveName.append(", " + caf::AppEnum<cvf::StructGridInterface::FaceType>::textFromIndex(geomSelectionItem->m_elementFace));
            }
            else
            {
                curveName.append(", from N[" + QString::number(timeHistResultAccessor->closestNodeId()) + "] transformed onto intersection");
            }
        }
        curveName.append("\n");

        curveName.append(timeHistResultAccessor->geometrySelectionText());

        std::vector<double> timeHistoryValues = timeHistResultAccessor->timeHistoryValues();

        std::vector<QDateTime> dates = geoMechView->geoMechCase()->timeStepDates();
        if (dates.size() == timeHistoryValues.size())
        {
            RiuMainWindow::instance()->resultPlot()->addCurve(geoMechView->geoMechCase(), curveName, geomSelectionItem->m_color, dates, timeHistoryValues);
        }
        else
        {
            std::vector<double> dummyStepTimes;
            for (size_t i = 0; i < timeHistoryValues.size(); i++)
            {
                dummyStepTimes.push_back(i);
            }

            RiuMainWindow::instance()->resultPlot()->addCurve(geoMechView->geoMechCase(), curveName, geomSelectionItem->m_color, dummyStepTimes, timeHistoryValues);
        }
    }
}