#1114 First working well communication lines operative

This commit is contained in:
Jacob Støren 2017-03-14 19:21:55 +01:00
parent d4c14d0f53
commit 1a42af5b37
7 changed files with 395 additions and 5 deletions

View File

@ -35,6 +35,8 @@ ${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.h
${CEE_CURRENT_LIST_DIR}RivSimWellPipeSourceInfo.h
${CEE_CURRENT_LIST_DIR}RivWellSpheresPartMgr.h
${CEE_CURRENT_LIST_DIR}RivPartPriority.h
${CEE_CURRENT_LIST_DIR}RivWellConnectionsPartMgr.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -65,6 +67,7 @@ ${CEE_CURRENT_LIST_DIR}RivPipeQuadToSegmentMapper.cpp
${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.cpp
${CEE_CURRENT_LIST_DIR}RivSimWellPipeSourceInfo.cpp
${CEE_CURRENT_LIST_DIR}RivWellSpheresPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivWellConnectionsPartMgr.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -37,6 +37,7 @@
#include "cvfTransform.h"
#include "RivWellSpheresPartMgr.h"
#include "RivWellConnectionsPartMgr.h"
//--------------------------------------------------------------------------------------------------
///
@ -152,6 +153,16 @@ void RivReservoirSimWellsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa
m_wellSpheresPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex);
}
}
// Well Connection Arrows
if ( m_reservoirView->wellCollection()->showWellCommunicationLines() )
{
for ( RimEclipseWell* rimWell : m_reservoirView->wellCollection()->wells() )
{
cvf::ref<RivWellConnectionsPartMgr> wppmgr = new RivWellConnectionsPartMgr(m_reservoirView, rimWell);
wppmgr->appendDynamicGeometryPartsToModel(model, frameIndex);
}
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -35,6 +35,7 @@ class RimEclipseView;
class RivSimWellPipesPartMgr;
class RivWellHeadPartMgr;
class RivWellSpheresPartMgr;
class RivWellConnectionsPartMgr;
class RivReservoirSimWellsPartMgr : public cvf::Object
{
@ -59,5 +60,6 @@ private:
cvf::Collection< RivSimWellPipesPartMgr > m_wellPipesPartMgrs;
cvf::Collection< RivWellHeadPartMgr > m_wellHeadPartMgrs;
cvf::Collection< RivWellSpheresPartMgr > m_wellSpheresPartMgrs;
cvf::Collection< RivWellConnectionsPartMgr > m_wellConnPartMgrs;
};

View File

@ -0,0 +1,257 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil ASA
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RivWellConnectionsPartMgr.h"
#include "RimEclipseResultCase.h"
#include "RimEclipseView.h"
#include "RimEclipseWell.h"
#include "RimEclipseWellCollection.h"
#include "RigSingleWellResultsData.h"
#include "RigFlowDiagResults.h"
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RigActiveCellInfo.h"
#include "cafEffectGenerator.h"
#include "cafDisplayCoordTransform.h"
#include "cvfDrawableGeo.h"
#include "cvfPart.h"
#include "cvfModelBasicList.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivWellConnectionsPartMgr::RivWellConnectionsPartMgr(RimEclipseView* reservoirView, RimEclipseWell* well)
{
m_rimReservoirView = reservoirView;
m_rimWell = well;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivWellConnectionsPartMgr::~RivWellConnectionsPartMgr()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellConnectionsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
{
if ( m_rimReservoirView.isNull() ) return;
if ( !m_rimReservoirView->eclipseCase() ) return;
if ( !m_rimWell->showWell() ) return;
if ( !m_rimWell->wellResults()->hasWellResult(frameIndex) ) return;
if ( !m_rimWell->wellResults()->wellResultFrame(frameIndex).m_isOpen ) return;
if ( m_rimWell->wellResults()->wellResultFrame(frameIndex).m_productionType == RigWellResultFrame::UNDEFINED_PRODUCTION_TYPE ) return;
bool isProducer = (m_rimWell->wellResults()->wellResultFrame(frameIndex).m_productionType == RigWellResultFrame::PRODUCER);
double pipeRadius = m_rimWell->pipeRadius();
cvf::Vec3d wellHeadTop;
cvf::Vec3d wellHeadBottom;
double characteristicCellSize;
double mainArrowZHeight;
cvf::ref<caf::DisplayCoordTransform> displayCordXf;
RigFlowDiagResults* flowResults;
std::string injectorName;
std::string producerName;
double fluxWidthScale = 0.0;
{
RimEclipseResultCase* eclResCase = dynamic_cast<RimEclipseResultCase*>(m_rimReservoirView->eclipseCase());
if ( !eclResCase ) return;
if ( !eclResCase->defaultFlowDiagSolution() ) return;
flowResults = eclResCase->defaultFlowDiagSolution()->flowDiagResults();
displayCordXf = m_rimReservoirView->displayCoordTransform();
RigEclipseCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData();
characteristicCellSize = rigReservoir->mainGrid()->characteristicIJCellSize();
m_rimWell->wellHeadTopBottomPosition(frameIndex, &wellHeadTop, &wellHeadBottom);
wellHeadTop = displayCordXf->transformToDisplayCoord(wellHeadTop);
wellHeadBottom = displayCordXf->transformToDisplayCoord(wellHeadBottom);
wellHeadTop.z() += characteristicCellSize;
cvf::Vec3d activeCellsBoundingBoxMax = displayCordXf->transformToDisplayCoord(m_rimReservoirView->currentActiveCellInfo()->geometryBoundingBox().max());
mainArrowZHeight = activeCellsBoundingBoxMax.z() - characteristicCellSize; // Above the bbox somewhat;
if ( isProducer ) producerName = m_rimWell->name().toStdString();
else injectorName = m_rimWell->name().toStdString();
double maxAbsFlux = flowResults->maxAbsPairFlux(static_cast<int>(frameIndex));
if (maxAbsFlux != 0.0) fluxWidthScale = characteristicCellSize / maxAbsFlux;
}
RimEclipseWellCollection* wellColl = m_rimReservoirView->wellCollection();
for ( RimEclipseWell * otherWell: wellColl->wells )
{
if ( otherWell == m_rimWell ) continue;
if ( !otherWell->showWell() ) continue;
if ( !otherWell->wellResults()->hasWellResult(frameIndex) ) continue;
if ( !otherWell->wellResults()->wellResultFrame(frameIndex).m_isOpen ) continue;
if ( otherWell->wellResults()->wellResultFrame(frameIndex).m_productionType == RigWellResultFrame::UNDEFINED_PRODUCTION_TYPE ) continue;
bool isOtherProducer = (otherWell->wellResults()->wellResultFrame(frameIndex).m_productionType == RigWellResultFrame::PRODUCER);
if (isProducer == isOtherProducer) continue;
if ( isOtherProducer ) producerName = otherWell->name().toStdString();
else injectorName = otherWell->name().toStdString();
std::pair<double, double> injProdFluxPair = flowResults->injectorProducerPairFluxes(injectorName, producerName, static_cast<int>(frameIndex));
if ( fabs(injProdFluxPair.first) < 1e-3 && fabs(injProdFluxPair.second) < 1e-3 ) continue;
float width = fluxWidthScale * (isProducer ? injProdFluxPair.second: injProdFluxPair.first);
cvf::Vec3d otherWellHeadTop;
cvf::Vec3d otherWellHeadBottom;
{
otherWell->wellHeadTopBottomPosition(frameIndex, &otherWellHeadTop, &otherWellHeadBottom);
otherWellHeadTop = displayCordXf->transformToDisplayCoord(otherWellHeadTop);
otherWellHeadBottom = displayCordXf->transformToDisplayCoord(otherWellHeadBottom);
otherWellHeadTop.z() += characteristicCellSize;
}
{
cvf::Vec3f startPoint = cvf::Vec3f(0.5*(wellHeadTop + otherWellHeadTop));
startPoint.z() = mainArrowZHeight;
cvf::Vec3f endPoint = cvf::Vec3f(wellHeadTop + (2* pipeRadius * (otherWellHeadTop - wellHeadTop).getNormalized()));
cvf::ref<cvf::Part> part = new cvf::Part;
cvf::ref<cvf::DrawableGeo> geo = createArrow(startPoint, endPoint, width, isProducer);
part->setDrawable(geo.p());
caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(otherWell->wellPipeColor()), caf::PO_1);
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
part->setEffect(eff.p());
model->addPart(part.p());
}
}
}
cvf::ref< cvf::DrawableGeo> RivWellConnectionsPartMgr::createArrow(const cvf::Vec3f& startPoint,
const cvf::Vec3f& endPoint,
double width,
bool useArrowEnd)
{
// 0 2 4 6 8 10 12 14
// : flat : : : : flat : : : end
// 1 3 5 7 9 11 13 15
// Producer end:
// 16
// 18
// 17
static const cvf::uint producerArrowFaceList[7 * 5 + 4] ={ 4, 0, 1, 3, 2,
4, 2, 3, 5, 4,
4, 4, 5, 7, 6,
4, 6, 7, 9, 8,
4, 8, 9, 11, 10,
4, 10, 11, 13, 12,
4, 12, 13, 15, 14,
3, 16, 17, 18 };
// Injector end
// 16
// 18
// 17
static const cvf::uint injectorArrowFaceList[7 * 5 + 8] ={ 4, 0, 1, 3, 2,
4, 2, 3, 5, 4,
4, 4, 5, 7, 6,
4, 6, 7, 9, 8,
4, 8, 9, 11, 10,
4, 10, 11, 13, 12,
4, 12, 13, 15, 14,
3, 14, 18, 16,
3, 18, 15, 17 };
cvf::Vec3f endPointInTopPlane = endPoint;
endPointInTopPlane.z() = startPoint.z();
cvf::Vec3f heightDiff = cvf::Vec3f::ZERO;
heightDiff.z() = 0.5*(startPoint.z() - endPoint.z());
cvf::Vec3f fromTo = endPointInTopPlane - startPoint;
float halfWidth = width * 0.5;
cvf::Vec3f widthVector = halfWidth *(fromTo.getNormalized() ^ -cvf::Vec3f::Z_AXIS);
cvf::ref< cvf::Vec3fArray> arrowVertexArray = new cvf::Vec3fArray;
arrowVertexArray->resize(16+3);
(*arrowVertexArray)[0] = 0.0f* fromTo + startPoint + widthVector;
(*arrowVertexArray)[1] = 0.0f* fromTo + startPoint - widthVector;
(*arrowVertexArray)[2] = 0.7f* fromTo + startPoint + widthVector;
(*arrowVertexArray)[3] = 0.7f* fromTo + startPoint - widthVector;
(*arrowVertexArray)[4] = (0.04f + 0.7f)* fromTo + startPoint + widthVector + 0.05f * heightDiff;
(*arrowVertexArray)[5] = (0.04f + 0.7f)* fromTo + startPoint - widthVector + 0.05f * heightDiff;
(*arrowVertexArray)[6] = (2*0.04f + 0.7f)* fromTo + startPoint + widthVector + 0.15f * heightDiff;
(*arrowVertexArray)[7] = (2*0.04f + 0.7f)* fromTo + startPoint - widthVector + 0.15f * heightDiff;
(*arrowVertexArray)[8] = (3*0.04f + 0.7f)* fromTo + startPoint + widthVector + 0.2f * heightDiff;
(*arrowVertexArray)[9] = (3*0.04f + 0.7f)* fromTo + startPoint - widthVector + 0.2f * heightDiff;
(*arrowVertexArray)[10] = (4*0.04f + 0.7f)* fromTo + startPoint + widthVector + 0.175f * heightDiff;
(*arrowVertexArray)[11] = (4*0.04f + 0.7f)* fromTo + startPoint - widthVector + 0.175f * heightDiff;
(*arrowVertexArray)[12] = (5*0.04f + 0.7f)* fromTo + startPoint + widthVector;
(*arrowVertexArray)[13] = (5*0.04f + 0.7f)* fromTo + startPoint - widthVector;
(*arrowVertexArray)[14] = (6*0.04f + 0.7f)* fromTo + startPoint + widthVector - 0.5f * heightDiff;
(*arrowVertexArray)[15] = (6*0.04f + 0.7f)* fromTo + startPoint - widthVector - 0.5f * heightDiff;
if ( useArrowEnd )
{
(*arrowVertexArray)[16] = (6*0.04f + 0.7f)* fromTo + startPoint + 1.1f*widthVector - 0.5f * heightDiff;
(*arrowVertexArray)[17] = (6*0.04f + 0.7f)* fromTo + startPoint - 1.1f*widthVector - 0.5f * heightDiff;
(*arrowVertexArray)[18] = 1.0f * fromTo + startPoint - 1.0f * heightDiff;
}
else
{
(*arrowVertexArray)[16] = 1.0f * fromTo + startPoint + 0.5f*widthVector - 1.0f * heightDiff;
(*arrowVertexArray)[17] = 1.0f * fromTo + startPoint - 0.5f*widthVector - 1.0f * heightDiff;
(*arrowVertexArray)[18] = (6*0.04f + 0.7f)* fromTo + startPoint - 0.5f * heightDiff;
}
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
geo->setVertexArray(arrowVertexArray.p());
if ( useArrowEnd )
geo->setFromFaceList(cvf::UIntArray(producerArrowFaceList, 7 * 5 + 4));
else
geo->setFromFaceList(cvf::UIntArray(injectorArrowFaceList, 7 * 5 + 8));
return geo;
}

View File

@ -0,0 +1,61 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil ASA
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmPointer.h"
#include "cvfVector3.h"
#include <list>
#include <vector>
#include <utility>
namespace cvf
{
class ModelBasicList;
class DrawableGeo;
}
class RivPipeGeometryGenerator;
class RimEclipseView;
class RimEclipseWell;
class RigWellResultFrame;
struct RigWellResultPoint;
class RivWellConnectionsPartMgr : public cvf::Object
{
public:
RivWellConnectionsPartMgr(RimEclipseView* reservoirView, RimEclipseWell* well);
~RivWellConnectionsPartMgr();
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex);
private:
cvf::ref< cvf::DrawableGeo> createArrow(const cvf::Vec3f& startPoint,
const cvf::Vec3f& endPoint,
double width,
bool useArrowEnd);
private:
caf::PdmPointer<RimEclipseView> m_rimReservoirView;
caf::PdmPointer<RimEclipseWell> m_rimWell;
};

View File

@ -38,6 +38,7 @@ RigFlowDiagResults::RigFlowDiagResults(RimFlowDiagSolution* flowSolution, size_t
m_timeStepCount = timeStepCount;
m_hasAtemptedNativeResults.resize(timeStepCount, false);
m_injProdPairFluxCommunicationTimesteps.resize(timeStepCount);
}
//--------------------------------------------------------------------------------------------------
@ -88,10 +89,20 @@ const std::vector<double>* RigFlowDiagResults::findOrCalculateResult(const RigFl
if (!solverInterface()) return nullptr;
if (!m_hasAtemptedNativeResults[frameIndex])
calculateNativeResultsIfNotPreviouslyAttempted(frameIndex);
return findScalarResultFrame(resVarAddr, frameIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagResults::calculateNativeResultsIfNotPreviouslyAttempted(size_t frameIndex)
{
if ( !m_hasAtemptedNativeResults[frameIndex] )
{
RigFlowDiagTimeStepResult nativeTimestepResults = solverInterface()->calculate(frameIndex,
RigFlowDiagTimeStepResult nativeTimestepResults = solverInterface()->calculate(frameIndex,
m_flowDiagSolution->allInjectorTracerActiveCellIndices(frameIndex),
m_flowDiagSolution->allProducerTracerActiveCellIndices(frameIndex));
@ -105,10 +116,10 @@ const std::vector<double>* RigFlowDiagResults::findOrCalculateResult(const RigFl
nativeResFrames->frameData(frameIndex).swap(resIt.second);
}
m_injProdPairFluxCommunicationTimesteps[frameIndex].swap(nativeTimestepResults.injProdWellPairFluxes());
m_hasAtemptedNativeResults[frameIndex] = true;
}
return findScalarResultFrame(resVarAddr, frameIndex);
}
//--------------------------------------------------------------------------------------------------
@ -583,3 +594,40 @@ const std::vector<int>& RigFlowDiagResults::uniqueCellScalarValues(const RigFlow
{
return this->statistics(resVarAddr)->uniqueCellScalarValues(frameIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<double, double> RigFlowDiagResults::injectorProducerPairFluxes(const std::string& injTracername,
const std::string& prodTracerName,
int frameIndex)
{
calculateNativeResultsIfNotPreviouslyAttempted(frameIndex);
auto commPair = m_injProdPairFluxCommunicationTimesteps[frameIndex].find(std::make_pair(injTracername, prodTracerName));
if (commPair != m_injProdPairFluxCommunicationTimesteps[frameIndex].end())
{
return commPair->second;
}
else
{
return std::make_pair(0.0, 0.0);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigFlowDiagResults::maxAbsPairFlux(int frameIndex)
{
calculateNativeResultsIfNotPreviouslyAttempted(frameIndex);
double maxFlux = 0.0;
for (const auto& commPair : m_injProdPairFluxCommunicationTimesteps[frameIndex])
{
if (fabs(commPair.second.first) > maxFlux ) maxFlux = commPair.second.first;
if (fabs(commPair.second.second) > maxFlux ) maxFlux = commPair.second.second;
}
return maxFlux;
}

View File

@ -59,8 +59,13 @@ public:
const std::vector<int>& uniqueCellScalarValues(const RigFlowDiagResultAddress& resVarAddr);
const std::vector<int>& uniqueCellScalarValues(const RigFlowDiagResultAddress& resVarAddr, int frameIndex);
std::pair<double, double> injectorProducerPairFluxes(const std::string& injTracername, const std::string& prodTracerName, int frameIndex);
double maxAbsPairFlux(int frameIndex);
private:
const std::vector<double>* findOrCalculateResult (const RigFlowDiagResultAddress& resVarAddr, size_t frameIndex);
void calculateNativeResultsIfNotPreviouslyAttempted(size_t frameIndex);
std::vector<double>* calculateDerivedResult(const RigFlowDiagResultAddress& resVarAddr, size_t frameIndex);
@ -104,6 +109,9 @@ private:
std::map< RigFlowDiagResultAddress, cvf::ref<RigFlowDiagResultFrames> > m_resultSets;
std::map< RigFlowDiagResultAddress, cvf::ref<RigStatisticsDataCache> > m_resultStatistics;
using InjectorProducerCommunicationMap = std::map<std::pair<std::string, std::string>, std::pair<double, double> >;
std::vector<InjectorProducerCommunicationMap> m_injProdPairFluxCommunicationTimesteps;
};