Example #1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicfSetTimeStep::execute()
{
    RimEclipseCase* eclipseCase = nullptr;

    {
        bool foundCase = false;
        for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels()->cases)
        {
            if (c->caseId == m_caseId)
            {
                eclipseCase = c;
                foundCase = true;
                break;
            }
        }
        if (!foundCase)
        {
            RiaLogging::error(QString("setTimeStep: Could not find case with ID %1").arg(m_caseId()));
            return;
        }
    }

    for (Rim3dView* view : eclipseCase->views())
    {
        view->setCurrentTimeStepAndUpdate(m_timeStepIndex);
    }
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicfExportSimWellFractureCompletions::execute()
{
    RimProject* project = RiaApplication::instance()->project();
    RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData();
    
    exportSettings->timeStep = m_timeStep;
    exportSettings->fileSplit = m_fileSplit;
    exportSettings->compdatExport = m_compdatExport;

    {
        bool foundCase = false;
        for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels->cases())
        {
            if (c->caseId() == m_caseId())
            {
                exportSettings->caseToApply = c;
                foundCase = true;
                break;
            }
        }
        if (!foundCase)
        {
            RiaLogging::error(QString("exportSimWellCompletions: Could not find case with ID %1").arg(m_caseId()));
            return;
        }
    }

    QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath(RicfCommandFileExecutor::COMPLETIONS);
    if (exportFolder.isNull())
    {
        exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath("completions");
    }
    exportSettings->folder = exportFolder;

    std::vector<RimEclipseView*> views;
    for (Rim3dView* v : exportSettings->caseToApply->views())
    {
        RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(v);
        if (eclipseView && eclipseView->name() == m_viewName())
        {
            views.push_back(eclipseView);
        }
    }
    if (views.empty())
    {
        RiaLogging::error(QString("exportSimWellCompletions: Could not find any views named \"%1\" in the case with ID %2").arg(m_viewName).arg(m_caseId()));
        return;
    }

    std::vector<RimSimWellInView*> simWells;
    if (m_simWellNames().empty())
    {
        for (RimEclipseView* view : views)
        {
            for (auto simWell : view->wellCollection()->wells)
            {
                if (simWell->showWell())
                {
                    simWells.push_back(simWell);
                }
            }
        }
    }
    else
    {
        for (const QString& wellPathName : m_simWellNames())
        {
            for (RimEclipseView* view : views)
            {
                RimSimWellInView* simWell = view->wellCollection()->findWell(wellPathName);
                if (simWell)
                {
                    simWells.push_back(simWell);
                }
                else
                {
                    RiaLogging::warning(QString("exportSimWellCompletions: Could not find well with name %1 in view \"%2\" on case with ID %2").arg(wellPathName).arg(m_viewName).arg(m_caseId()));
                }
            }
        }
    }

    std::vector<RimWellPath*> wellPaths;

    RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings);
}