2012-05-18 02:45:23 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-05-06 03:55:00 -05:00
|
|
|
//#include "RiaStdInclude.h"
|
|
|
|
#include "RimWell.h"
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
|
|
|
|
#include "cafAppEnum.h"
|
|
|
|
#include "cafPdmField.h"
|
|
|
|
#include "RivReservoirViewPartMgr.h"
|
|
|
|
#include "RimReservoirView.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
#include "RimWellCollection.h"
|
|
|
|
#include "cafPdmFieldCvfMat4d.h"
|
|
|
|
#include "cafPdmFieldCvfColor.h"
|
|
|
|
#include "RimResultSlot.h"
|
|
|
|
#include "RimCellEdgeResultSlot.h"
|
|
|
|
#include "Rim3dOverlayInfoConfig.h"
|
|
|
|
#include "RimCellPropertyFilterCollection.h"
|
|
|
|
#include "RimCellRangeFilterCollection.h"
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimWell, "Well");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWell::RimWell()
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("Well", ":/Well.png", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&name, "WellName", "Name", "", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitField(&showWellLabel, "ShowWellLabel", true, "Show well label", "", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitField(&showWellPipes, "ShowWellPipe", true, "Show well pipe", "", "", "");
|
2013-04-24 03:38:50 -05:00
|
|
|
CAF_PDM_InitField(&pipeRadiusScaleFactor, "WellPipeRadiusScale",1.0, "Pipe radius scale", "", "", "");
|
|
|
|
CAF_PDM_InitField(&wellPipeColor, "WellPipeColor", cvf::Color3f(0.588f, 0.588f, 0.804f), "Well pipe color", "", "", "");
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
CAF_PDM_InitField(&showWellCells, "ShowWellCells", true, "Add cells to range filter", "", "", "");
|
2013-04-24 03:38:50 -05:00
|
|
|
CAF_PDM_InitField(&showWellCellFence, "ShowWellCellFence", false, "Use well fence", "", "", "");
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2012-06-26 09:10:41 -05:00
|
|
|
name.setUiHidden(true);
|
|
|
|
name.setUiReadOnly(true);
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-04-26 09:46:38 -05:00
|
|
|
m_wellIndex = cvf::UNDEFINED_SIZE_T;
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
m_reservoirView = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWell::~RimWell()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmFieldHandle* RimWell::userDescriptionField()
|
|
|
|
{
|
|
|
|
return &name;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWell::setReservoirView(RimReservoirView* ownerReservoirView)
|
|
|
|
{
|
|
|
|
m_reservoirView = ownerReservoirView;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWell::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
|
|
|
if (&showWellLabel == changedField)
|
|
|
|
{
|
|
|
|
if (m_reservoirView)
|
|
|
|
{
|
|
|
|
m_reservoirView->createDisplayModelAndRedraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (&showWellCells == changedField)
|
|
|
|
{
|
|
|
|
if (m_reservoirView)
|
|
|
|
{
|
|
|
|
m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS);
|
|
|
|
m_reservoirView->createDisplayModelAndRedraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (&showWellCellFence == changedField)
|
|
|
|
{
|
|
|
|
if (m_reservoirView)
|
|
|
|
{
|
|
|
|
m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS);
|
|
|
|
m_reservoirView->createDisplayModelAndRedraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (&showWellPipes == changedField)
|
|
|
|
{
|
|
|
|
if (m_reservoirView) m_reservoirView->createDisplayModelAndRedraw();
|
|
|
|
}
|
|
|
|
else if (&wellPipeColor == changedField)
|
|
|
|
{
|
|
|
|
if (m_reservoirView) m_reservoirView->createDisplayModelAndRedraw();
|
|
|
|
}
|
|
|
|
else if (&pipeRadiusScaleFactor == changedField)
|
|
|
|
{
|
2013-02-08 07:59:27 -06:00
|
|
|
if (m_reservoirView)
|
|
|
|
{
|
|
|
|
m_reservoirView->schedulePipeGeometryRegen();
|
|
|
|
m_reservoirView->createDisplayModelAndRedraw();
|
|
|
|
}
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-17 01:25:32 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmFieldHandle* RimWell::objectToggleField()
|
|
|
|
{
|
|
|
|
return &showWellPipes;
|
|
|
|
}
|
|
|
|
|
2013-04-22 02:13:37 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-04-26 09:46:38 -05:00
|
|
|
bool RimWell::calculateWellPipeVisibility(size_t frameIndex)
|
2013-04-22 02:13:37 -05:00
|
|
|
{
|
|
|
|
if (m_reservoirView == NULL) return false;
|
|
|
|
if (this->wellResults() == NULL) return false;
|
|
|
|
|
2013-08-26 14:56:40 -05:00
|
|
|
if (frameIndex >= this->wellResults()->m_resultTimeStepIndexToWellTimeStepIndex.size())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t wellTimeStepIndex = this->wellResults()->m_resultTimeStepIndexToWellTimeStepIndex[frameIndex];
|
|
|
|
if (wellTimeStepIndex == cvf::UNDEFINED_SIZE_T)
|
|
|
|
{
|
2013-08-12 10:05:03 -05:00
|
|
|
return false;
|
2013-08-26 14:56:40 -05:00
|
|
|
}
|
2013-08-12 10:05:03 -05:00
|
|
|
|
2013-08-26 14:56:40 -05:00
|
|
|
if (!m_reservoirView->wellCollection()->isActive())
|
2013-04-26 09:46:38 -05:00
|
|
|
return false;
|
|
|
|
|
2013-04-22 02:13:37 -05:00
|
|
|
if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_FORCE_ALL_ON)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_FORCE_ALL_OFF)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ( this->showWellPipes() == false )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_INDIVIDUALLY)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_OPEN_IN_VISIBLE_CELLS)
|
|
|
|
{
|
|
|
|
const std::vector<RivReservoirViewPartMgr::ReservoirGeometryCacheType>& visGridParts = m_reservoirView->visibleGridParts();
|
|
|
|
cvf::cref<RivReservoirViewPartMgr> rvMan = m_reservoirView->reservoirGridPartManager();
|
|
|
|
|
|
|
|
for (size_t gpIdx = 0; gpIdx < visGridParts.size(); ++gpIdx)
|
|
|
|
{
|
|
|
|
const RigWellResultFrame& wrsf = this->wellResults()->wellResultFrame(frameIndex);
|
|
|
|
|
|
|
|
// First check the wellhead:
|
|
|
|
|
|
|
|
size_t gridIndex = wrsf.m_wellHead.m_gridIndex;
|
|
|
|
size_t gridCellIndex = wrsf.m_wellHead.m_gridCellIndex;
|
|
|
|
|
|
|
|
cvf::cref<cvf::UByteArray> cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex);
|
|
|
|
if ((*cellVisibility)[gridCellIndex])
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Then check the rest of the well, with all the branches
|
|
|
|
|
|
|
|
const std::vector<RigWellResultBranch>& wellResSegments = wrsf.m_wellResultBranches;
|
|
|
|
for (size_t wsIdx = 0; wsIdx < wellResSegments.size(); ++wsIdx)
|
|
|
|
{
|
2013-08-26 07:03:01 -05:00
|
|
|
const std::vector<RigWellResultPoint>& wsResCells = wellResSegments[wsIdx].m_branchResultPoints;
|
2013-04-22 02:13:37 -05:00
|
|
|
for (size_t cIdx = 0; cIdx < wsResCells.size(); ++ cIdx)
|
|
|
|
{
|
2013-08-26 07:03:01 -05:00
|
|
|
if (wsResCells[cIdx].isCell())
|
2013-04-22 02:13:37 -05:00
|
|
|
{
|
2013-08-26 06:56:42 -05:00
|
|
|
gridIndex = wsResCells[cIdx].m_gridIndex;
|
|
|
|
gridCellIndex = wsResCells[cIdx].m_gridCellIndex;
|
|
|
|
|
|
|
|
cvf::cref<cvf::UByteArray> cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex);
|
|
|
|
if ((*cellVisibility)[gridCellIndex])
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2013-04-22 02:13:37 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
CVF_ASSERT(false); // Never end here. have you added new pipe visibility modes ?
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-24 03:38:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWell::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
|
|
|
{
|
|
|
|
caf::PdmUiGroup* pipeGroup = uiOrdering.addNewGroup("Well pipe");
|
|
|
|
pipeGroup->add(&showWellPipes);
|
|
|
|
pipeGroup->add(&pipeRadiusScaleFactor);
|
|
|
|
pipeGroup->add(&wellPipeColor);
|
2013-04-24 23:33:37 -05:00
|
|
|
pipeGroup->add(&showWellLabel);
|
2013-04-24 03:38:50 -05:00
|
|
|
|
|
|
|
caf::PdmUiGroup* filterGroup = uiOrdering.addNewGroup("Range filter");
|
|
|
|
filterGroup->add(&showWellCells);
|
|
|
|
filterGroup->add(&showWellCellFence);
|
|
|
|
}
|
|
|
|
|
2013-04-26 09:46:38 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimWell::isWellPipeVisible(size_t frameIndex)
|
|
|
|
{
|
2013-04-29 04:08:31 -05:00
|
|
|
CVF_ASSERT(m_wellIndex != cvf::UNDEFINED_SIZE_T);
|
|
|
|
|
2013-04-26 09:46:38 -05:00
|
|
|
// Return the possibly cached value
|
|
|
|
return m_reservoirView->wellCollection()->isWellPipesVisible(frameIndex)[m_wellIndex];
|
|
|
|
}
|
|
|
|
|