mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1577 Improve RigWellPathIntersectionTools
This commit is contained in:
@@ -15,6 +15,7 @@ ${CEE_CURRENT_LIST_DIR}RigResultAccessorFactory.h
|
||||
${CEE_CURRENT_LIST_DIR}RigAllGridCellsResultAccessor.h
|
||||
${CEE_CURRENT_LIST_DIR}RigActiveCellsResultAccessor.h
|
||||
${CEE_CURRENT_LIST_DIR}RigCellEdgeResultAccessor.h
|
||||
${CEE_CURRENT_LIST_DIR}RigCellGeometryTools.h
|
||||
${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessor.h
|
||||
${CEE_CURRENT_LIST_DIR}RigCombMultResultAccessor.h
|
||||
${CEE_CURRENT_LIST_DIR}RigCompletionData.h
|
||||
@@ -70,6 +71,7 @@ ${CEE_CURRENT_LIST_DIR}RigResultAccessorFactory.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigAllGridCellsResultAccessor.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigActiveCellsResultAccessor.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigCellEdgeResultAccessor.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigCellGeometryTools.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessor.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigCombMultResultAccessor.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigCompletionData.cpp
|
||||
|
||||
67
ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp
Normal file
67
ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- 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 "RigCellGeometryTools.h"
|
||||
|
||||
#include "cvfStructGrid.h"
|
||||
#include "cvfGeometryTools.h"
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
void RigCellGeometryTools::findCellLocalXYZ(const std::array<cvf::Vec3d, 8>& hexCorners, cvf::Vec3d& localXdirection, cvf::Vec3d& localYdirection, cvf::Vec3d& localZdirection)
|
||||
{
|
||||
cvf::ubyte faceVertexIndices[4];
|
||||
cvf::StructGridInterface::FaceEnum face;
|
||||
|
||||
face = cvf::StructGridInterface::NEG_I;
|
||||
cvf::StructGridInterface::cellFaceVertexIndices(face, faceVertexIndices);
|
||||
cvf::Vec3d faceCenterNegI = cvf::GeometryTools::computeFaceCenter(hexCorners[faceVertexIndices[0]], hexCorners[faceVertexIndices[1]], hexCorners[faceVertexIndices[2]], hexCorners[faceVertexIndices[3]]);
|
||||
//TODO: Should we use face centroids instead of face centers?
|
||||
|
||||
face = cvf::StructGridInterface::POS_I;
|
||||
cvf::StructGridInterface::cellFaceVertexIndices(face, faceVertexIndices);
|
||||
cvf::Vec3d faceCenterPosI = cvf::GeometryTools::computeFaceCenter(hexCorners[faceVertexIndices[0]], hexCorners[faceVertexIndices[1]], hexCorners[faceVertexIndices[2]], hexCorners[faceVertexIndices[3]]);
|
||||
|
||||
face = cvf::StructGridInterface::NEG_J;
|
||||
cvf::StructGridInterface::cellFaceVertexIndices(face, faceVertexIndices);
|
||||
cvf::Vec3d faceCenterNegJ = cvf::GeometryTools::computeFaceCenter(hexCorners[faceVertexIndices[0]], hexCorners[faceVertexIndices[1]], hexCorners[faceVertexIndices[2]], hexCorners[faceVertexIndices[3]]);
|
||||
|
||||
face = cvf::StructGridInterface::POS_J;
|
||||
cvf::StructGridInterface::cellFaceVertexIndices(face, faceVertexIndices);
|
||||
cvf::Vec3d faceCenterPosJ = cvf::GeometryTools::computeFaceCenter(hexCorners[faceVertexIndices[0]], hexCorners[faceVertexIndices[1]], hexCorners[faceVertexIndices[2]], hexCorners[faceVertexIndices[3]]);
|
||||
|
||||
cvf::Vec3d faceCenterCenterVectorI = faceCenterPosI - faceCenterNegI;
|
||||
cvf::Vec3d faceCenterCenterVectorJ = faceCenterPosJ - faceCenterNegJ;
|
||||
|
||||
localZdirection.cross(faceCenterCenterVectorI, faceCenterCenterVectorJ);
|
||||
localZdirection.normalize();
|
||||
|
||||
cvf::Vec3d crossPoductJZ;
|
||||
crossPoductJZ.cross(faceCenterCenterVectorJ, localZdirection);
|
||||
localXdirection = faceCenterCenterVectorI + crossPoductJZ;
|
||||
localXdirection.normalize();
|
||||
|
||||
cvf::Vec3d crossPoductIZ;
|
||||
crossPoductIZ.cross(faceCenterCenterVectorI, localZdirection);
|
||||
localYdirection = faceCenterCenterVectorJ - crossPoductIZ;
|
||||
localYdirection.normalize();
|
||||
|
||||
//TODO: Check if we end up with 0-vectors, and handle this case...
|
||||
}
|
||||
35
ApplicationCode/ReservoirDataModel/RigCellGeometryTools.h
Normal file
35
ApplicationCode/ReservoirDataModel/RigCellGeometryTools.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- 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 "cvfVector3.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
class RigCellGeometryTools
|
||||
{
|
||||
public:
|
||||
static void findCellLocalXYZ(const std::array<cvf::Vec3d, 8>& hexCorners, cvf::Vec3d &localXdirection, cvf::Vec3d &localYdirection, cvf::Vec3d &localZdirection);
|
||||
};
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigWellLogExtractionTools.h"
|
||||
#include "RigCellGeometryTools.h"
|
||||
|
||||
#include "cvfGeometryTools.h"
|
||||
#include "cvfMatrix3.h"
|
||||
@@ -46,7 +47,7 @@ std::vector<WellPathCellIntersectionInfo> RigWellPathIntersectionTools::findCell
|
||||
cvf::Vec3d startPoint;
|
||||
cvf::Vec3d endPoint;
|
||||
size_t cellIndex;
|
||||
WellPathCellDirection direction;
|
||||
cvf::Vec3d internalCellLengths;
|
||||
|
||||
auto intersection = intersections.cbegin();
|
||||
|
||||
@@ -58,8 +59,8 @@ std::vector<WellPathCellIntersectionInfo> RigWellPathIntersectionTools::findCell
|
||||
if (foundCell)
|
||||
{
|
||||
endPoint = intersection->m_intersectionPoint;
|
||||
direction = calculateDirectionInCell(grid, cellIndex, startPoint, endPoint);
|
||||
intersectionInfo.push_back(WellPathCellIntersectionInfo(cellIndex, direction, startPoint, endPoint));
|
||||
internalCellLengths = calculateLengthInCell(grid, cellIndex, startPoint, endPoint);
|
||||
intersectionInfo.push_back(WellPathCellIntersectionInfo(cellIndex, startPoint, endPoint, internalCellLengths));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -75,8 +76,8 @@ std::vector<WellPathCellIntersectionInfo> RigWellPathIntersectionTools::findCell
|
||||
while (intersection != intersections.cend())
|
||||
{
|
||||
endPoint = intersection->m_intersectionPoint;
|
||||
direction = calculateDirectionInCell(grid, cellIndex, startPoint, endPoint);
|
||||
intersectionInfo.push_back(WellPathCellIntersectionInfo(cellIndex, direction, startPoint, endPoint));
|
||||
internalCellLengths = calculateLengthInCell(grid, cellIndex, startPoint, endPoint);
|
||||
intersectionInfo.push_back(WellPathCellIntersectionInfo(cellIndex, startPoint, endPoint, internalCellLengths));
|
||||
|
||||
startPoint = endPoint;
|
||||
cellIndex = intersection->m_hexIndex;
|
||||
@@ -86,8 +87,8 @@ std::vector<WellPathCellIntersectionInfo> RigWellPathIntersectionTools::findCell
|
||||
if (includeEndCell)
|
||||
{
|
||||
endPoint = coords[coords.size() - 1];
|
||||
direction = calculateDirectionInCell(grid, cellIndex, startPoint, endPoint);
|
||||
intersectionInfo.push_back(WellPathCellIntersectionInfo(cellIndex, direction, startPoint, endPoint));
|
||||
internalCellLengths = calculateLengthInCell(grid, cellIndex, startPoint, endPoint);
|
||||
intersectionInfo.push_back(WellPathCellIntersectionInfo(cellIndex, startPoint, endPoint, internalCellLengths));
|
||||
}
|
||||
|
||||
return intersectionInfo;
|
||||
@@ -124,107 +125,35 @@ std::vector<HexIntersectionInfo> RigWellPathIntersectionTools::getIntersectedCel
|
||||
return intersections;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Calculates main axis vectors for each axis in the cell.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigWellPathIntersectionTools::calculateCellMainAxisVectors(const std::array<cvf::Vec3d, 8>& hexCorners, cvf::Vec3d* iAxisDirection, cvf::Vec3d* jAxisDirection, cvf::Vec3d* kAxisDirection)
|
||||
{
|
||||
*iAxisDirection = calculateCellMainAxisVector(hexCorners, cvf::StructGridInterface::NEG_I, cvf::StructGridInterface::POS_I);
|
||||
*jAxisDirection = calculateCellMainAxisVector(hexCorners, cvf::StructGridInterface::NEG_J, cvf::StructGridInterface::POS_J);
|
||||
*kAxisDirection = calculateCellMainAxisVector(hexCorners, cvf::StructGridInterface::NEG_K, cvf::StructGridInterface::POS_K);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Calculate the main axis vector for one axis in the cell, fron `negativeFace` to `positiveFace`
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3d RigWellPathIntersectionTools::calculateCellMainAxisVector(const std::array<cvf::Vec3d, 8>& hexCorners,
|
||||
cvf::StructGridInterface::FaceType negativeFace,
|
||||
cvf::StructGridInterface::FaceType positiveFace)
|
||||
{
|
||||
cvf::ubyte negativeFaceVertexIndices[4];
|
||||
cvf::StructGridInterface::cellFaceVertexIndices(negativeFace, negativeFaceVertexIndices);
|
||||
cvf::Vec3d negativeFaceCenter = cvf::GeometryTools::computeFaceCenter(hexCorners[negativeFaceVertexIndices[0]],
|
||||
hexCorners[negativeFaceVertexIndices[1]],
|
||||
hexCorners[negativeFaceVertexIndices[2]],
|
||||
hexCorners[negativeFaceVertexIndices[3]]);
|
||||
|
||||
cvf::ubyte positiveFaceVertexIndices[4];
|
||||
cvf::StructGridInterface::cellFaceVertexIndices(positiveFace, positiveFaceVertexIndices);
|
||||
cvf::Vec3d positiveFaceCenter = cvf::GeometryTools::computeFaceCenter(hexCorners[positiveFaceVertexIndices[0]],
|
||||
hexCorners[positiveFaceVertexIndices[1]],
|
||||
hexCorners[positiveFaceVertexIndices[2]],
|
||||
hexCorners[positiveFaceVertexIndices[3]]);
|
||||
|
||||
return positiveFaceCenter - negativeFaceCenter;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
WellPathCellDirection RigWellPathIntersectionTools::calculateDirectionInCell(const std::array<cvf::Vec3d, 8>& hexCorners, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint)
|
||||
cvf::Vec3d RigWellPathIntersectionTools::calculateLengthInCell(const std::array<cvf::Vec3d, 8>& hexCorners, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint)
|
||||
{
|
||||
cvf::Vec3d vec = endPoint - startPoint;
|
||||
cvf::Vec3d iAxisDirection;
|
||||
cvf::Vec3d jAxisDirection;
|
||||
cvf::Vec3d kAxisDirection;
|
||||
|
||||
cvf::Vec3d iAxisVector;
|
||||
cvf::Vec3d jAxisVector;
|
||||
cvf::Vec3d kAxisVector;
|
||||
calculateCellMainAxisVectors(hexCorners, &iAxisVector, &jAxisVector, &kAxisVector);
|
||||
|
||||
cvf::Vec3d iAxisDirection = iAxisVector.getNormalized();
|
||||
cvf::Vec3d jAxisDirection = jAxisVector.getNormalized();
|
||||
cvf::Vec3d kAxisDirection = kAxisVector.getNormalized();
|
||||
RigCellGeometryTools::findCellLocalXYZ(hexCorners, iAxisDirection, jAxisDirection, kAxisDirection);
|
||||
|
||||
cvf::Mat3d localCellCoordinateSystem(iAxisDirection.x(), jAxisDirection.x(), kAxisDirection.x(),
|
||||
iAxisDirection.y(), jAxisDirection.y(), kAxisDirection.y(),
|
||||
iAxisDirection.z(), jAxisDirection.z(), kAxisDirection.z());
|
||||
|
||||
cvf::Vec3d localCellCoordinateVec = vec.getTransformedVector(localCellCoordinateSystem.getInverted());
|
||||
|
||||
double iLengthFraction = abs(localCellCoordinateVec.x() / iAxisVector.length());
|
||||
double jLengthFraction = abs(localCellCoordinateVec.y() / jAxisVector.length());
|
||||
double kLengthFraction = abs(localCellCoordinateVec.z() / kAxisVector.length());
|
||||
|
||||
if (iLengthFraction > jLengthFraction && iLengthFraction > kLengthFraction)
|
||||
{
|
||||
WellPathCellDirection direction = POS_I;
|
||||
if (localCellCoordinateVec.x() < 0)
|
||||
{
|
||||
direction = NEG_I;
|
||||
}
|
||||
return direction;
|
||||
}
|
||||
else if (jLengthFraction > iLengthFraction && jLengthFraction > kLengthFraction)
|
||||
{
|
||||
WellPathCellDirection direction = POS_J;
|
||||
if (localCellCoordinateVec.y() < 0)
|
||||
{
|
||||
direction = NEG_J;
|
||||
}
|
||||
return direction;
|
||||
}
|
||||
else
|
||||
{
|
||||
WellPathCellDirection direction = POS_K;
|
||||
if (localCellCoordinateVec.z() < 0)
|
||||
{
|
||||
direction = NEG_K;
|
||||
}
|
||||
return direction;
|
||||
}
|
||||
|
||||
return vec.getTransformedVector(localCellCoordinateSystem.getInverted());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
WellPathCellDirection RigWellPathIntersectionTools::calculateDirectionInCell(const RigMainGrid* grid, size_t cellIndex, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint)
|
||||
cvf::Vec3d RigWellPathIntersectionTools::calculateLengthInCell(const RigMainGrid* grid, size_t cellIndex, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint)
|
||||
{
|
||||
std::array<cvf::Vec3d, 8> hexCorners = getCellHexCorners(grid, cellIndex);
|
||||
|
||||
return calculateDirectionInCell(hexCorners, startPoint, endPoint);
|
||||
return calculateLengthInCell(hexCorners, startPoint, endPoint);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -30,33 +30,21 @@ class RigWellPath;
|
||||
class RigMainGrid;
|
||||
class RigEclipseCaseData;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
enum WellPathCellDirection {
|
||||
POS_I,
|
||||
NEG_I,
|
||||
POS_J,
|
||||
NEG_J,
|
||||
POS_K,
|
||||
NEG_K
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
struct WellPathCellIntersectionInfo {
|
||||
WellPathCellIntersectionInfo(size_t cellIndex, WellPathCellDirection direction, cvf::Vec3d startPoint, cvf::Vec3d endPoint)
|
||||
WellPathCellIntersectionInfo(size_t cellIndex, cvf::Vec3d startPoint, cvf::Vec3d endPoint, cvf::Vec3d internalCellLengths)
|
||||
: cellIndex(cellIndex),
|
||||
direction(direction),
|
||||
startPoint(startPoint),
|
||||
endPoint(endPoint)
|
||||
endPoint(endPoint),
|
||||
internalCellLengths(internalCellLengths)
|
||||
{}
|
||||
|
||||
size_t cellIndex;
|
||||
WellPathCellDirection direction;
|
||||
cvf::Vec3d startPoint;
|
||||
cvf::Vec3d endPoint;
|
||||
size_t cellIndex;
|
||||
cvf::Vec3d startPoint;
|
||||
cvf::Vec3d endPoint;
|
||||
cvf::Vec3d internalCellLengths;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
@@ -69,11 +57,8 @@ public:
|
||||
|
||||
static std::vector<HexIntersectionInfo> getIntersectedCells(const RigMainGrid* grid, const std::vector<cvf::Vec3d>& coords);
|
||||
|
||||
// Calculate direction
|
||||
static void calculateCellMainAxisVectors(const std::array<cvf::Vec3d, 8>& hexCorners, cvf::Vec3d* iAxisDirection, cvf::Vec3d* jAxisDirection, cvf::Vec3d* kAxisDirection);
|
||||
static cvf::Vec3d calculateCellMainAxisVector(const std::array<cvf::Vec3d, 8>& hexCorners, cvf::StructGridInterface::FaceType startFace, cvf::StructGridInterface::FaceType endFace);
|
||||
static WellPathCellDirection calculateDirectionInCell(const std::array<cvf::Vec3d, 8>& hexCorners, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint);
|
||||
static WellPathCellDirection calculateDirectionInCell(const RigMainGrid* grid, size_t cellIndex, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint);
|
||||
static cvf::Vec3d calculateLengthInCell(const std::array<cvf::Vec3d, 8>& hexCorners, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint);
|
||||
static cvf::Vec3d calculateLengthInCell(const RigMainGrid* grid, size_t cellIndex, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint);
|
||||
|
||||
static std::vector<size_t> findCloseCells(const RigMainGrid* grid, const cvf::BoundingBox& bb);
|
||||
static size_t findCellFromCoords(const RigMainGrid* caseData, const cvf::Vec3d& coords, bool* foundCell);
|
||||
|
||||
Reference in New Issue
Block a user