#2544 Well CF Visualization: Add geometry generator and source info object

rename


remove unused


move to separate file


rename
This commit is contained in:
Magne Sjaastad 2018-03-15 21:25:54 +01:00
parent eb6b7450eb
commit 4853957637
10 changed files with 596 additions and 392 deletions

View File

@ -39,7 +39,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RivTensorResultPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.h
${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogPlanePartMgr.h ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogPlanePartMgr.h
${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.h ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RivVirtualConnFactorPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorGeometryGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionSourceInfo.h
) )
set (SOURCE_GROUP_SOURCE_FILES set (SOURCE_GROUP_SOURCE_FILES
@ -77,7 +79,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RivTensorResultPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogPlanePartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogPlanePartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.cpp ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RivVirtualConnFactorPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorGeometryGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionSourceInfo.cpp
) )
list(APPEND CODE_HEADER_FILES list(APPEND CODE_HEADER_FILES

View File

@ -1,352 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 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 "RivVirtualConnFactorPartMgr.h"
#include "RiaApplication.h"
#include "RiaExtractionTools.h"
#include "RigEclipseWellLogExtractor.h"
#include "RigMainGrid.h"
#include "RigVirtualPerforationTransmissibilities.h"
#include "RigWellLogExtractor.h"
#include "RigWellPath.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimLegendConfig.h"
#include "RimSimWellInViewCollection.h"
#include "RimVirtualPerforationResults.h"
#include "RimWellPath.h"
#include "RiuViewer.h"
#include "cafDisplayCoordTransform.h"
#include "cafEffectGenerator.h"
#include "cafPdmFieldCvfColor.h"
#include "cafPdmFieldCvfMat4d.h"
#include "cvfDrawableGeo.h"
#include "cvfGeometryBuilderFaceList.h"
#include "cvfGeometryBuilderTriangles.h"
#include "cvfGeometryUtils.h"
#include "cvfModelBasicList.h"
#include "cvfObject.h"
#include "cvfPart.h"
#include "cvfPrimitiveSetIndexedUInt.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivVirtualConnFactorPartMgr::RivVirtualConnFactorPartMgr(RimWellPath* well,
RimVirtualPerforationResults* virtualPerforationResult)
: m_rimWell(well)
, m_virtualPerforationResult(virtualPerforationResult)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivVirtualConnFactorPartMgr::~RivVirtualConnFactorPartMgr() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
{
RimEclipseView* eclView = nullptr;
m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted(eclView);
auto coordTransform = eclView->displayCoordTransform();
RimEclipseCase* eclipseCase = nullptr;
m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted(eclipseCase);
const RigMainGrid* mainGrid = eclipseCase->mainGrid();
const RigVirtualPerforationTransmissibilities* trans = eclipseCase->computeAndGetVirtualPerforationTransmissibilities();
if (!trans) return;
auto conn = trans->multipleCompletionsPerEclipseCell(m_rimWell, frameIndex);
std::vector<WellPathCellIntersectionInfo> wellPathCellIntersections;
{
RigEclipseWellLogExtractor* extractor = RiaExtractionTools::wellLogExtractorEclipseCase(m_rimWell, eclipseCase);
if (extractor)
{
wellPathCellIntersections = extractor->cellIntersectionInfosAlongWellPath();
}
}
std::vector<CompletionVizData> centerColorPairs;
for (const auto& cell : conn)
{
size_t gridIndex = cell.first.globalCellIndex();
const RigCell& rigCell = mainGrid->cell(gridIndex);
cvf::Vec3d locationInDomainCoord = rigCell.center();
cvf::Vec3d wellPathDirection = cvf::Vec3d::X_AXIS;
if (!wellPathCellIntersections.empty())
{
for (const auto& intersectionInfo : wellPathCellIntersections)
{
if (intersectionInfo.globCellIndex == cell.first.globalCellIndex())
{
double startMD = intersectionInfo.startMD;
double endMD = intersectionInfo.endMD;
double middleMD = (startMD + endMD) / 2.0;
locationInDomainCoord = m_rimWell->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD);
cvf::Vec3d p1;
cvf::Vec3d p2;
m_rimWell->wellPathGeometry()->twoClosestPoints(locationInDomainCoord, &p1, &p2);
wellPathDirection = (p2 - p1).getNormalized();
continue;
}
}
}
cvf::Vec3d displayCoord = coordTransform->transformToDisplayCoord(locationInDomainCoord);
double transmissibility = HUGE_VAL;
if (!cell.second.empty())
{
transmissibility = cell.second.front().transmissibility();
}
centerColorPairs.push_back(CompletionVizData(displayCoord, wellPathDirection, transmissibility));
}
if (!centerColorPairs.empty())
{
double radius = mainGrid->characteristicIJCellSize() * m_virtualPerforationResult->geometryScaleFactor();
auto scalarMapper = m_virtualPerforationResult->legendConfig()->scalarMapper();
bool disableLighting = eclView->isLightingDisabled();
cvf::ref<cvf::Part> part =
RivVirtualConnFactorPartMgr::createPart(centerColorPairs, radius, scalarMapper, disableLighting);
model->addPart(part.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> RivVirtualConnFactorPartMgr::createPart(std::vector<CompletionVizData>& vizDataItems,
double radius,
cvf::ScalarMapper* scalarMapper,
bool disableLighting)
{
std::vector<cvf::Vec3f> verticesForOneObject;
std::vector<cvf::uint> indicesForOneObject;
RivVirtualConnFactorPartMgr::createStarGeometry(&verticesForOneObject, &indicesForOneObject, radius, radius * 0.3);
cvf::ref<cvf::Vec3fArray> vertices = new cvf::Vec3fArray;
cvf::ref<cvf::UIntArray> indices = new cvf::UIntArray;
cvf::ref<cvf::Vec2fArray> textureCoords = new cvf::Vec2fArray();
auto indexCount = vizDataItems.size() * indicesForOneObject.size();
auto vertexCount = vizDataItems.size() * verticesForOneObject.size();
indices->reserve(indexCount);
vertices->reserve(vertexCount);
textureCoords->reserve(vertexCount);
textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f));
for (const auto& item : vizDataItems)
{
auto rotMatrix = rotationMatrixBetweenVectors(cvf::Vec3d::Y_AXIS, item.m_direction);
cvf::uint indexOffset = static_cast<cvf::uint>(vertices->size());
for (const auto& v : verticesForOneObject)
{
auto rotatedPoint = v.getTransformedPoint(rotMatrix);
vertices->add(cvf::Vec3f(item.m_anchor) + rotatedPoint);
if (item.m_connectionFactor == HUGE_VAL)
{
textureCoords->add(cvf::Vec2f(0.5f, 1.0f));
}
else
{
textureCoords->add(scalarMapper->mapToTextureCoord(item.m_connectionFactor));
}
}
for (const auto& i : indicesForOneObject)
{
indices->add(i + indexOffset);
}
}
cvf::ref<cvf::DrawableGeo> drawable = new cvf::DrawableGeo();
drawable->setVertexArray(vertices.p());
drawable->addPrimitiveSet(new cvf::PrimitiveSetIndexedUInt(cvf::PT_TRIANGLES, indices.p()));
drawable->computeNormals();
drawable->setTextureCoordArray(textureCoords.p());
cvf::ref<cvf::Part> part = new cvf::Part;
part->setDrawable(drawable.p());
caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1);
effGen.disableLighting(disableLighting);
cvf::ref<cvf::Effect> eff = effGen.generateCachedEffect();
part->setEffect(eff.p());
return part;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivVirtualConnFactorPartMgr::createStarGeometry(std::vector<cvf::Vec3f>* vertices,
std::vector<cvf::uint>* indices,
double radius,
double thickness)
{
auto p0 = cvf::Vec3f::Z_AXIS * radius;
auto p2 = cvf::Vec3f::X_AXIS * -radius;
auto p4 = -p0;
auto p6 = -p2;
double innerFactor = 5.0;
auto p1 = (p0 + p2) / innerFactor;
auto p3 = (p2 + p4) / innerFactor;
auto p5 = -p1;
auto p7 = -p3;
auto p8 = cvf::Vec3f::Y_AXIS * thickness;
auto p9 = -p8;
vertices->push_back(p0);
vertices->push_back(p1);
vertices->push_back(p2);
vertices->push_back(p3);
vertices->push_back(p4);
vertices->push_back(p5);
vertices->push_back(p6);
vertices->push_back(p7);
vertices->push_back(p8);
vertices->push_back(p9);
// Top
indices->push_back(0);
indices->push_back(1);
indices->push_back(8);
indices->push_back(0);
indices->push_back(8);
indices->push_back(7);
indices->push_back(0);
indices->push_back(9);
indices->push_back(1);
indices->push_back(0);
indices->push_back(7);
indices->push_back(9);
// Left
indices->push_back(2);
indices->push_back(3);
indices->push_back(8);
indices->push_back(2);
indices->push_back(8);
indices->push_back(1);
indices->push_back(2);
indices->push_back(9);
indices->push_back(3);
indices->push_back(2);
indices->push_back(1);
indices->push_back(9);
// Bottom
indices->push_back(4);
indices->push_back(5);
indices->push_back(8);
indices->push_back(4);
indices->push_back(8);
indices->push_back(3);
indices->push_back(4);
indices->push_back(9);
indices->push_back(5);
indices->push_back(4);
indices->push_back(3);
indices->push_back(9);
// Right
indices->push_back(6);
indices->push_back(7);
indices->push_back(8);
indices->push_back(6);
indices->push_back(8);
indices->push_back(5);
indices->push_back(6);
indices->push_back(9);
indices->push_back(7);
indices->push_back(6);
indices->push_back(5);
indices->push_back(9);
}
//--------------------------------------------------------------------------------------------------
/// Taken from OverlayNavigationCube::computeNewUpVector
/// Consider move to geometry util class
//--------------------------------------------------------------------------------------------------
cvf::Mat4f RivVirtualConnFactorPartMgr::rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2)
{
using namespace cvf;
Vec3d rotAxis = v1 ^ v2;
rotAxis.normalize();
// Guard acos against out-of-domain input
const double dotProduct = Math::clamp(v1 * v2, -1.0, 1.0);
const double angle = Math::acos(dotProduct);
Mat4d rotMat = Mat4d::fromRotation(rotAxis, angle);
Mat4f myMat(rotMat);
return myMat;
}

View File

@ -0,0 +1,222 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 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 "RivWellConnectionFactorGeometryGenerator.h"
#include "cvfArray.h"
#include "cvfDrawableGeo.h"
#include "cvfPrimitiveSetIndexedUInt.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellConnectionFactorGeometryGenerator::createStarGeometry(std::vector<cvf::Vec3f>* vertices,
std::vector<cvf::uint>* indices,
float radius,
float thickness)
{
auto p0 = cvf::Vec3f::Z_AXIS * radius;
auto p2 = cvf::Vec3f::X_AXIS * -radius;
auto p4 = -p0;
auto p6 = -p2;
float innerFactor = 5.0f;
auto p1 = (p0 + p2) / innerFactor;
auto p3 = (p2 + p4) / innerFactor;
auto p5 = -p1;
auto p7 = -p3;
auto p8 = cvf::Vec3f::Y_AXIS * thickness;
auto p9 = -p8;
vertices->push_back(p0);
vertices->push_back(p1);
vertices->push_back(p2);
vertices->push_back(p3);
vertices->push_back(p4);
vertices->push_back(p5);
vertices->push_back(p6);
vertices->push_back(p7);
vertices->push_back(p8);
vertices->push_back(p9);
// Top
indices->push_back(0);
indices->push_back(1);
indices->push_back(8);
indices->push_back(0);
indices->push_back(8);
indices->push_back(7);
indices->push_back(0);
indices->push_back(9);
indices->push_back(1);
indices->push_back(0);
indices->push_back(7);
indices->push_back(9);
// Left
indices->push_back(2);
indices->push_back(3);
indices->push_back(8);
indices->push_back(2);
indices->push_back(8);
indices->push_back(1);
indices->push_back(2);
indices->push_back(9);
indices->push_back(3);
indices->push_back(2);
indices->push_back(1);
indices->push_back(9);
// Bottom
indices->push_back(4);
indices->push_back(5);
indices->push_back(8);
indices->push_back(4);
indices->push_back(8);
indices->push_back(3);
indices->push_back(4);
indices->push_back(9);
indices->push_back(5);
indices->push_back(4);
indices->push_back(3);
indices->push_back(9);
// Right
indices->push_back(6);
indices->push_back(7);
indices->push_back(8);
indices->push_back(6);
indices->push_back(8);
indices->push_back(5);
indices->push_back(6);
indices->push_back(9);
indices->push_back(7);
indices->push_back(6);
indices->push_back(5);
indices->push_back(9);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivWellConnectionFactorGeometryGenerator::RivWellConnectionFactorGeometryGenerator(
std::vector<CompletionVizData>& centerColorPairs,
float radius)
: m_centerColorPairs(centerColorPairs)
, m_radius(radius)
, m_trianglesPerConnection(0)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivWellConnectionFactorGeometryGenerator::~RivWellConnectionFactorGeometryGenerator() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivWellConnectionFactorGeometryGenerator::createPipeSurface()
{
std::vector<cvf::Vec3f> verticesForOneObject;
std::vector<cvf::uint> indicesForOneObject;
RivWellConnectionFactorGeometryGenerator::createStarGeometry(
&verticesForOneObject, &indicesForOneObject, m_radius, m_radius * 0.3f);
cvf::ref<cvf::Vec3fArray> vertices = new cvf::Vec3fArray;
cvf::ref<cvf::UIntArray> indices = new cvf::UIntArray;
auto indexCount = m_centerColorPairs.size() * indicesForOneObject.size();
auto vertexCount = m_centerColorPairs.size() * verticesForOneObject.size();
indices->reserve(indexCount);
vertices->reserve(vertexCount);
for (const auto& item : m_centerColorPairs)
{
auto rotMatrix = rotationMatrixBetweenVectors(cvf::Vec3d::Y_AXIS, item.m_direction);
cvf::uint indexOffset = static_cast<cvf::uint>(vertices->size());
for (const auto& v : verticesForOneObject)
{
auto rotatedPoint = v.getTransformedPoint(rotMatrix);
vertices->add(cvf::Vec3f(item.m_anchor) + rotatedPoint);
}
for (const auto& i : indicesForOneObject)
{
indices->add(i + indexOffset);
}
}
cvf::ref<cvf::DrawableGeo> drawable = new cvf::DrawableGeo();
drawable->setVertexArray(vertices.p());
drawable->addPrimitiveSet(new cvf::PrimitiveSetIndexedUInt(cvf::PT_TRIANGLES, indices.p()));
drawable->computeNormals();
return drawable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RivWellConnectionFactorGeometryGenerator::globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const
{
size_t connectionIndex = triangleIndex / m_trianglesPerConnection;
return m_centerColorPairs[connectionIndex].m_globalCellIndex;
}
//--------------------------------------------------------------------------------------------------
/// Taken from OverlayNavigationCube::computeNewUpVector
/// Consider move to geometry util class
//--------------------------------------------------------------------------------------------------
cvf::Mat4f RivWellConnectionFactorGeometryGenerator::rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2)
{
using namespace cvf;
Vec3d rotAxis = v1 ^ v2;
rotAxis.normalize();
// Guard acos against out-of-domain input
const double dotProduct = Math::clamp(v1 * v2, -1.0, 1.0);
const double angle = Math::acos(dotProduct);
Mat4d rotMat = Mat4d::fromRotation(rotAxis, angle);
Mat4f myMat(rotMat);
return myMat;
}

View File

@ -19,68 +19,56 @@
#pragma once #pragma once
#include "cvfBase.h" #include "cvfBase.h"
#include "cvfMatrix4.h"
#include "cvfObject.h" #include "cvfObject.h"
#include "cvfVector3.h" #include "cvfVector3.h"
#include "cvfMatrix4.h"
#include "cafPdmPointer.h"
#include <vector> #include <vector>
namespace cvf namespace cvf
{ {
class Part; class DrawableGeo;
class ModelBasicList;
class ScalarMapper;
} // namespace cvf } // namespace cvf
class RimWellPath; //--------------------------------------------------------------------------------------------------
class RimVirtualPerforationResults; ///
//--------------------------------------------------------------------------------------------------
namespace caf
{
class DisplayCoordTransform;
}
struct CompletionVizData struct CompletionVizData
{ {
CompletionVizData(cvf::Vec3d anchor, cvf::Vec3d direction, double connectionFactor) CompletionVizData(const cvf::Vec3d& anchor, const cvf::Vec3d& direction, double connectionFactor, size_t globalCellIndex)
: m_anchor(anchor) : m_anchor(anchor)
, m_direction(direction) , m_direction(direction)
, m_connectionFactor(connectionFactor) , m_connectionFactor(connectionFactor)
, m_globalCellIndex(globalCellIndex)
{ {
} }
cvf::Vec3d m_anchor; cvf::Vec3d m_anchor;
cvf::Vec3d m_direction; cvf::Vec3d m_direction;
double m_connectionFactor; double m_connectionFactor;
size_t m_globalCellIndex;
}; };
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
/// Based on RivWellSpheresPartMgr
///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
class RivVirtualConnFactorPartMgr : public cvf::Object class RivWellConnectionFactorGeometryGenerator : public cvf::Object
{ {
public: public:
RivVirtualConnFactorPartMgr(RimWellPath* well, RimVirtualPerforationResults* virtualPerforationResult); RivWellConnectionFactorGeometryGenerator(std::vector<CompletionVizData>& centerColorPairs, float radius);
~RivVirtualConnFactorPartMgr(); ~RivWellConnectionFactorGeometryGenerator();
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); cvf::ref<cvf::DrawableGeo> createPipeSurface();
size_t globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const;
private: private:
static cvf::ref<cvf::Part> createPart(std::vector<CompletionVizData>& centerColorPairs,
double radius,
cvf::ScalarMapper* scalarMapper,
bool disableLighting);
static void createStarGeometry(std::vector<cvf::Vec3f>* vertices, std::vector<cvf::uint>* indices, double radius, double thickness);
static cvf::Mat4f rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2); static cvf::Mat4f rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2);
static void
createStarGeometry(std::vector<cvf::Vec3f>* vertices, std::vector<cvf::uint>* indices, float radius, float thickness);
private: private:
caf::PdmPointer<RimWellPath> m_rimWell; std::vector<CompletionVizData> m_centerColorPairs;
caf::PdmPointer<RimVirtualPerforationResults> m_virtualPerforationResult; float m_radius;
size_t m_trianglesPerConnection;
}; };

View File

@ -0,0 +1,193 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 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 "RivWellConnectionFactorPartMgr.h"
#include "RiaApplication.h"
#include "RiaExtractionTools.h"
#include "RigEclipseWellLogExtractor.h"
#include "RigMainGrid.h"
#include "RigVirtualPerforationTransmissibilities.h"
#include "RigWellLogExtractor.h"
#include "RigWellPath.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimLegendConfig.h"
#include "RimSimWellInViewCollection.h"
#include "RimVirtualPerforationResults.h"
#include "RimWellPath.h"
#include "RiuViewer.h"
#include "RivWellConnectionFactorGeometryGenerator.h"
#include "RivWellConnectionSourceInfo.h"
#include "cafDisplayCoordTransform.h"
#include "cafEffectGenerator.h"
#include "cvfDrawableGeo.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivWellConnectionFactorPartMgr::RivWellConnectionFactorPartMgr(RimWellPath* well,
RimVirtualPerforationResults* virtualPerforationResult)
: m_rimWell(well)
, m_virtualPerforationResult(virtualPerforationResult)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivWellConnectionFactorPartMgr::~RivWellConnectionFactorPartMgr() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
{
m_geometryGenerator = nullptr;
RimEclipseView* eclView = nullptr;
m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted(eclView);
auto coordTransform = eclView->displayCoordTransform();
RimEclipseCase* eclipseCase = nullptr;
m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted(eclipseCase);
const RigMainGrid* mainGrid = eclipseCase->mainGrid();
const RigVirtualPerforationTransmissibilities* trans = eclipseCase->computeAndGetVirtualPerforationTransmissibilities();
if (!trans) return;
auto conn = trans->multipleCompletionsPerEclipseCell(m_rimWell, frameIndex);
std::vector<WellPathCellIntersectionInfo> wellPathCellIntersections;
{
RigEclipseWellLogExtractor* extractor = RiaExtractionTools::wellLogExtractorEclipseCase(m_rimWell, eclipseCase);
if (extractor)
{
wellPathCellIntersections = extractor->cellIntersectionInfosAlongWellPath();
}
}
std::vector<size_t> mapFromConnectionIndexToGlobalCellIndex;
std::vector<CompletionVizData> centerColorPairs;
for (const auto& cell : conn)
{
size_t gridIndex = cell.first.globalCellIndex();
const RigCell& rigCell = mainGrid->cell(gridIndex);
cvf::Vec3d locationInDomainCoord = rigCell.center();
cvf::Vec3d wellPathDirection = cvf::Vec3d::X_AXIS;
if (!wellPathCellIntersections.empty())
{
for (const auto& intersectionInfo : wellPathCellIntersections)
{
if (intersectionInfo.globCellIndex == cell.first.globalCellIndex())
{
double startMD = intersectionInfo.startMD;
double endMD = intersectionInfo.endMD;
double middleMD = (startMD + endMD) / 2.0;
locationInDomainCoord = m_rimWell->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD);
cvf::Vec3d p1;
cvf::Vec3d p2;
m_rimWell->wellPathGeometry()->twoClosestPoints(locationInDomainCoord, &p1, &p2);
wellPathDirection = (p2 - p1).getNormalized();
continue;
}
}
}
cvf::Vec3d displayCoord = coordTransform->transformToDisplayCoord(locationInDomainCoord);
double transmissibility = HUGE_VAL;
if (!cell.second.empty())
{
transmissibility = cell.second.front().transmissibility();
}
centerColorPairs.push_back(
CompletionVizData(displayCoord, wellPathDirection, transmissibility, cell.first.globalCellIndex()));
mapFromConnectionIndexToGlobalCellIndex.push_back(cell.first.globalCellIndex());
}
if (!centerColorPairs.empty())
{
double radius = mainGrid->characteristicIJCellSize() * m_virtualPerforationResult->geometryScaleFactor();
m_geometryGenerator = new RivWellConnectionFactorGeometryGenerator(centerColorPairs, radius);
auto drawable = m_geometryGenerator->createPipeSurface();
cvf::ref<cvf::Part> part = new cvf::Part;
part->setDrawable(drawable.p());
auto scalarMapper = m_virtualPerforationResult->legendConfig()->scalarMapper();
// Compute texture coords
cvf::ref<cvf::Vec2fArray> textureCoords = new cvf::Vec2fArray();
{
textureCoords->reserve(drawable->vertexArray()->size());
size_t verticesPerItem = drawable->vertexArray()->size() / centerColorPairs.size();
textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f));
for (const auto& item : centerColorPairs)
{
cvf::Vec2f textureCoord = cvf::Vec2f(0.5f, 1.0f);
if (item.m_connectionFactor != HUGE_VAL)
{
textureCoord = scalarMapper->mapToTextureCoord(item.m_connectionFactor);
}
for (size_t i = 0; i < verticesPerItem; i++)
{
textureCoords->add(textureCoord);
}
}
}
drawable->setTextureCoordArray(textureCoords.p());
caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1);
bool disableLighting = eclView->isLightingDisabled();
effGen.disableLighting(disableLighting);
cvf::ref<cvf::Effect> eff = effGen.generateCachedEffect();
part->setEffect(eff.p());
cvf::ref<RivWellConnectionSourceInfo> sourceInfo = new RivWellConnectionSourceInfo(m_rimWell, m_geometryGenerator.p());
part->setSourceInfo(sourceInfo.p());
model->addPart(part.p());
}
}

View File

@ -0,0 +1,53 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 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 <vector>
namespace cvf
{
class ModelBasicList;
} // namespace cvf
class RimWellPath;
class RimVirtualPerforationResults;
class RivWellConnectionFactorGeometryGenerator;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RivWellConnectionFactorPartMgr : public cvf::Object
{
public:
RivWellConnectionFactorPartMgr(RimWellPath* well, RimVirtualPerforationResults* virtualPerforationResult);
~RivWellConnectionFactorPartMgr();
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex);
private:
caf::PdmPointer<RimWellPath> m_rimWell;
caf::PdmPointer<RimVirtualPerforationResults> m_virtualPerforationResult;
cvf::ref<RivWellConnectionFactorGeometryGenerator> m_geometryGenerator;
};

View File

@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 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 "RivWellConnectionSourceInfo.h"
#include "RimWellPath.h"
#include "RivWellConnectionFactorGeometryGenerator.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivWellConnectionSourceInfo::RivWellConnectionSourceInfo(RimWellPath* wellPath,
RivWellConnectionFactorGeometryGenerator* geometryGenerator)
: m_wellPath(wellPath)
, m_geometryGenerator(geometryGenerator)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPath* RivWellConnectionSourceInfo::wellPath() const
{
return m_wellPath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RivWellConnectionSourceInfo::globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const
{
if (m_geometryGenerator.isNull()) return 0;
return m_geometryGenerator->globalCellIndexFromTriangleIndex(triangleIndex);
}

View File

@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 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 "cafPdmPointer.h"
#include "cvfBase.h"
#include "cvfObject.h"
#include <vector>
class RimWellPath;
class RivWellConnectionFactorGeometryGenerator;
//==================================================================================================
///
//==================================================================================================
class RivWellConnectionSourceInfo : public cvf::Object
{
public:
explicit RivWellConnectionSourceInfo(RimWellPath* wellPath, RivWellConnectionFactorGeometryGenerator* geometryGenerator);
RimWellPath* wellPath() const;
size_t globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const;
private:
caf::PdmPointer<RimWellPath> m_wellPath;
cvf::ref<RivWellConnectionFactorGeometryGenerator> m_geometryGenerator;
};

View File

@ -47,6 +47,7 @@
#include "RivObjectSourceInfo.h" #include "RivObjectSourceInfo.h"
#include "RivPartPriority.h" #include "RivPartPriority.h"
#include "RivPipeGeometryGenerator.h" #include "RivPipeGeometryGenerator.h"
#include "RivWellConnectionFactorPartMgr.h"
#include "RivWellFracturePartMgr.h" #include "RivWellFracturePartMgr.h"
#include "RivWellPathPartMgr.h" #include "RivWellPathPartMgr.h"
#include "RivWellPathSourceInfo.h" #include "RivWellPathSourceInfo.h"
@ -63,7 +64,6 @@
#include "cvfScalarMapperDiscreteLinear.h" #include "cvfScalarMapperDiscreteLinear.h"
#include "cvfTransform.h" #include "cvfTransform.h"
#include "cvfqtUtils.h" #include "cvfqtUtils.h"
#include "RivVirtualConnFactorPartMgr.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -178,7 +178,7 @@ void RivWellPathPartMgr::appendPerforationsToModel(cvf::ModelBasicList* model,
size_t timeStepIndex = m_rimView->currentTimeStep(); size_t timeStepIndex = m_rimView->currentTimeStep();
std::vector<QDateTime> timeStamps = eclipseCase->timeStepDates(); std::vector<QDateTime> timeStamps = eclipseCase->timeStepDates();
if (timeStepIndex < static_cast<int>(timeStamps.size())) if (timeStepIndex < timeStamps.size())
{ {
currentTimeStamp = timeStamps[timeStepIndex]; currentTimeStamp = timeStamps[timeStepIndex];
} }
@ -238,11 +238,11 @@ void RivWellPathPartMgr::appendVirtualTransmissibilitiesToModel(cvf::ModelBasicL
const RigVirtualPerforationTransmissibilities* trans = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); const RigVirtualPerforationTransmissibilities* trans = eclipseCase->computeAndGetVirtualPerforationTransmissibilities();
if (trans) if (trans)
{ {
m_virtualConnectionFactorPartMgr = new RivVirtualConnFactorPartMgr(m_rimWellPath, eclView->virtualPerforationResult()); m_wellConnectionFactorPartMgr = new RivWellConnectionFactorPartMgr(m_rimWellPath, eclView->virtualPerforationResult());
size_t timeStepIndex = m_rimView->currentTimeStep(); size_t timeStepIndex = m_rimView->currentTimeStep();
m_virtualConnectionFactorPartMgr->appendDynamicGeometryPartsToModel(model, timeStepIndex); m_wellConnectionFactorPartMgr->appendDynamicGeometryPartsToModel(model, timeStepIndex);
} }
} }

View File

@ -46,7 +46,7 @@ class RivFishbonesSubsPartMgr;
class RimWellPathCollection; class RimWellPathCollection;
class Rim3dView; class Rim3dView;
class Riv3dWellLogPlanePartMgr; class Riv3dWellLogPlanePartMgr;
class RivVirtualConnFactorPartMgr; class RivWellConnectionFactorPartMgr;
class QDateTime; class QDateTime;
@ -110,6 +110,6 @@ private:
cvf::ref<cvf::DrawableGeo> m_centerLineDrawable; cvf::ref<cvf::DrawableGeo> m_centerLineDrawable;
cvf::ref<cvf::Part> m_wellLabelPart; cvf::ref<cvf::Part> m_wellLabelPart;
cvf::ref<Riv3dWellLogPlanePartMgr> m_3dWellLogCurvePartMgr; cvf::ref<Riv3dWellLogPlanePartMgr> m_3dWellLogCurvePartMgr;
cvf::ref<RivVirtualConnFactorPartMgr> m_virtualConnectionFactorPartMgr; cvf::ref<RivWellConnectionFactorPartMgr> m_wellConnectionFactorPartMgr;
}; };