#1577 Improve RigWellPathIntersectionTools

This commit is contained in:
Bjørnar Grip Fjær 2017-06-07 16:04:34 +02:00
parent 960948e684
commit b82bda5905
8 changed files with 160 additions and 245 deletions

View File

@ -30,6 +30,8 @@
#include "RimFishboneWellPathCollection.h" #include "RimFishboneWellPathCollection.h"
#include "RimPerforationInterval.h" #include "RimPerforationInterval.h"
#include "RimPerforationCollection.h" #include "RimPerforationCollection.h"
#include "RimReservoirCellResultsStorage.h"
#include "RicExportCompletionDataSettingsUi.h" #include "RicExportCompletionDataSettingsUi.h"
#include "RiuMainWindow.h" #include "RiuMainWindow.h"
@ -39,6 +41,7 @@
#include "RigEclipseCaseData.h" #include "RigEclipseCaseData.h"
#include "RigMainGrid.h" #include "RigMainGrid.h"
#include "RigWellPath.h" #include "RigWellPath.h"
#include "RigResultAccessorFactory.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cafPdmUiPropertyViewDialog.h" #include "cafPdmUiPropertyViewDialog.h"
@ -327,7 +330,7 @@ std::vector<RigCompletionData> RicWellPathExportCompletionDataFeature::generateF
RigCompletionData completion(wellPath->name(), IJKCellIndex(i, j, k)); RigCompletionData completion(wellPath->name(), IJKCellIndex(i, j, k));
completion.addMetadata(location.fishbonesSubs->name(), QString("Sub: %1 Lateral: %2").arg(location.subIndex).arg(lateral.lateralIndex)); completion.addMetadata(location.fishbonesSubs->name(), QString("Sub: %1 Lateral: %2").arg(location.subIndex).arg(lateral.lateralIndex));
double diameter = location.fishbonesSubs->holeDiameter() / 1000; double diameter = location.fishbonesSubs->holeDiameter() / 1000;
CellDirection direction = wellPathCellDirectionToCellDirection(intersection.direction); CellDirection direction = calculateDirectionInCell(settings.caseToApply, intersection.cellIndex, intersection.lengthsInCell);
completion.setFromFishbone(diameter, direction); completion.setFromFishbone(diameter, direction);
completionData.push_back(completion); completionData.push_back(completion);
} }
@ -340,7 +343,7 @@ std::vector<RigCompletionData> RicWellPathExportCompletionDataFeature::generateF
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<RigCompletionData> RicWellPathExportCompletionDataFeature::generateFishbonesWellPathCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi & settings) std::vector<RigCompletionData> RicWellPathExportCompletionDataFeature::generateFishbonesWellPathCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings)
{ {
std::vector<RigCompletionData> completionData; std::vector<RigCompletionData> completionData;
@ -354,7 +357,7 @@ std::vector<RigCompletionData> RicWellPathExportCompletionDataFeature::generateF
settings.caseToApply->eclipseCaseData()->mainGrid()->ijkFromCellIndex(cell.cellIndex, &i, &j, &k); settings.caseToApply->eclipseCaseData()->mainGrid()->ijkFromCellIndex(cell.cellIndex, &i, &j, &k);
RigCompletionData completion(wellPath->name(), IJKCellIndex(i, j, k)); RigCompletionData completion(wellPath->name(), IJKCellIndex(i, j, k));
completion.addMetadata(fishbonesPath->name(), ""); completion.addMetadata(fishbonesPath->name(), "");
CellDirection direction = wellPathCellDirectionToCellDirection(cell.direction); CellDirection direction = calculateDirectionInCell(settings.caseToApply, cell.cellIndex, cell.internalCellLengths);
completion.setFromFishbone(diameter, direction); completion.setFromFishbone(diameter, direction);
completionData.push_back(completion); completionData.push_back(completion);
} }
@ -383,7 +386,7 @@ std::vector<RigCompletionData> RicWellPathExportCompletionDataFeature::generateP
RigCompletionData completion(wellPath->name(), IJKCellIndex(i, j, k)); RigCompletionData completion(wellPath->name(), IJKCellIndex(i, j, k));
completion.addMetadata("Perforation", QString("StartMD: %1 - EndMD: %2").arg(interval->startMD()).arg(interval->endMD())); completion.addMetadata("Perforation", QString("StartMD: %1 - EndMD: %2").arg(interval->startMD()).arg(interval->endMD()));
double diameter = interval->diameter(); double diameter = interval->diameter();
CellDirection direction = wellPathCellDirectionToCellDirection(cell.direction); CellDirection direction = calculateDirectionInCell(settings.caseToApply, cell.cellIndex, cell.internalCellLengths);
completion.setFromPerforation(diameter, direction); completion.setFromPerforation(diameter, direction);
completionData.push_back(completion); completionData.push_back(completion);
} }
@ -517,7 +520,7 @@ void RicWellPathExportCompletionDataFeature::calculateLateralIntersections(const
depth += intersection->endPoint.z() - startPoint.z(); depth += intersection->endPoint.z() - startPoint.z();
WellSegmentLateralIntersection lateralIntersection(++(*segmentNum), attachedSegmentNumber, intersection->cellIndex, length, depth); WellSegmentLateralIntersection lateralIntersection(++(*segmentNum), attachedSegmentNumber, intersection->cellIndex, length, depth);
lateralIntersection.direction = intersection->direction; lateralIntersection.lengthsInCell = intersection->internalCellLengths;
lateral.intersections.push_back(lateralIntersection); lateral.intersections.push_back(lateralIntersection);
length = 0; length = 0;
@ -579,20 +582,31 @@ void RicWellPathExportCompletionDataFeature::appendCompletionData(std::map<IJKCe
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
CellDirection RicWellPathExportCompletionDataFeature::wellPathCellDirectionToCellDirection(WellPathCellDirection direction) CellDirection RicWellPathExportCompletionDataFeature::calculateDirectionInCell(RimEclipseCase* eclipseCase, size_t cellIndex, const cvf::Vec3d& lengthsInCell)
{ {
switch (direction) RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData();
eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DX");
cvf::ref<RigResultAccessor> dxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RifReaderInterface::MATRIX_RESULTS, 0, "DX");
eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DY");
cvf::ref<RigResultAccessor> dyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RifReaderInterface::MATRIX_RESULTS, 0, "DY");
eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DZ");
cvf::ref<RigResultAccessor> dzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RifReaderInterface::MATRIX_RESULTS, 0, "DZ");
double xLengthFraction = abs(lengthsInCell.x() / dxAccessObject->cellScalarGlobIdx(cellIndex));
double yLengthFraction = abs(lengthsInCell.y() / dyAccessObject->cellScalarGlobIdx(cellIndex));
double zLengthFraction = abs(lengthsInCell.z() / dzAccessObject->cellScalarGlobIdx(cellIndex));
if (xLengthFraction > yLengthFraction && xLengthFraction > zLengthFraction)
{ {
case POS_I:
case NEG_I:
return CellDirection::DIR_I; return CellDirection::DIR_I;
case POS_J: }
case NEG_J: else if (yLengthFraction > xLengthFraction && yLengthFraction > zLengthFraction)
{
return CellDirection::DIR_J; return CellDirection::DIR_J;
case POS_K: }
case NEG_K: else
{
return CellDirection::DIR_K; return CellDirection::DIR_K;
default:
return CellDirection::DIR_UNDEF;
} }
} }

View File

@ -48,7 +48,6 @@ struct WellSegmentLateralIntersection {
cellIndex(cellIndex), cellIndex(cellIndex),
length(length), length(length),
depth(depth), depth(depth),
direction(POS_I),
mainBoreCell(false) mainBoreCell(false)
{} {}
@ -58,7 +57,7 @@ struct WellSegmentLateralIntersection {
bool mainBoreCell; bool mainBoreCell;
double length; double length;
double depth; double depth;
WellPathCellDirection direction; cvf::Vec3d lengthsInCell;
}; };
//================================================================================================== //==================================================================================================
@ -151,5 +150,5 @@ private:
static void appendCompletionData(std::map<IJKCellIndex, RigCompletionData>* completionData, const std::vector<RigCompletionData>& data); static void appendCompletionData(std::map<IJKCellIndex, RigCompletionData>* completionData, const std::vector<RigCompletionData>& data);
static CellDirection wellPathCellDirectionToCellDirection(WellPathCellDirection direction); static CellDirection calculateDirectionInCell(RimEclipseCase* eclipseCase, size_t cellIndex, const cvf::Vec3d& lengthsInCell);
}; };

View File

@ -15,6 +15,7 @@ ${CEE_CURRENT_LIST_DIR}RigResultAccessorFactory.h
${CEE_CURRENT_LIST_DIR}RigAllGridCellsResultAccessor.h ${CEE_CURRENT_LIST_DIR}RigAllGridCellsResultAccessor.h
${CEE_CURRENT_LIST_DIR}RigActiveCellsResultAccessor.h ${CEE_CURRENT_LIST_DIR}RigActiveCellsResultAccessor.h
${CEE_CURRENT_LIST_DIR}RigCellEdgeResultAccessor.h ${CEE_CURRENT_LIST_DIR}RigCellEdgeResultAccessor.h
${CEE_CURRENT_LIST_DIR}RigCellGeometryTools.h
${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessor.h ${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessor.h
${CEE_CURRENT_LIST_DIR}RigCombMultResultAccessor.h ${CEE_CURRENT_LIST_DIR}RigCombMultResultAccessor.h
${CEE_CURRENT_LIST_DIR}RigCompletionData.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}RigAllGridCellsResultAccessor.cpp
${CEE_CURRENT_LIST_DIR}RigActiveCellsResultAccessor.cpp ${CEE_CURRENT_LIST_DIR}RigActiveCellsResultAccessor.cpp
${CEE_CURRENT_LIST_DIR}RigCellEdgeResultAccessor.cpp ${CEE_CURRENT_LIST_DIR}RigCellEdgeResultAccessor.cpp
${CEE_CURRENT_LIST_DIR}RigCellGeometryTools.cpp
${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessor.cpp ${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessor.cpp
${CEE_CURRENT_LIST_DIR}RigCombMultResultAccessor.cpp ${CEE_CURRENT_LIST_DIR}RigCombMultResultAccessor.cpp
${CEE_CURRENT_LIST_DIR}RigCompletionData.cpp ${CEE_CURRENT_LIST_DIR}RigCompletionData.cpp

View 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...
}

View 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);
};

View File

@ -24,6 +24,7 @@
#include "RigMainGrid.h" #include "RigMainGrid.h"
#include "RigEclipseCaseData.h" #include "RigEclipseCaseData.h"
#include "RigWellLogExtractionTools.h" #include "RigWellLogExtractionTools.h"
#include "RigCellGeometryTools.h"
#include "cvfGeometryTools.h" #include "cvfGeometryTools.h"
#include "cvfMatrix3.h" #include "cvfMatrix3.h"
@ -46,7 +47,7 @@ std::vector<WellPathCellIntersectionInfo> RigWellPathIntersectionTools::findCell
cvf::Vec3d startPoint; cvf::Vec3d startPoint;
cvf::Vec3d endPoint; cvf::Vec3d endPoint;
size_t cellIndex; size_t cellIndex;
WellPathCellDirection direction; cvf::Vec3d internalCellLengths;
auto intersection = intersections.cbegin(); auto intersection = intersections.cbegin();
@ -58,8 +59,8 @@ std::vector<WellPathCellIntersectionInfo> RigWellPathIntersectionTools::findCell
if (foundCell) if (foundCell)
{ {
endPoint = intersection->m_intersectionPoint; endPoint = intersection->m_intersectionPoint;
direction = calculateDirectionInCell(grid, cellIndex, startPoint, endPoint); internalCellLengths = calculateLengthInCell(grid, cellIndex, startPoint, endPoint);
intersectionInfo.push_back(WellPathCellIntersectionInfo(cellIndex, direction, startPoint, endPoint)); intersectionInfo.push_back(WellPathCellIntersectionInfo(cellIndex, startPoint, endPoint, internalCellLengths));
} }
else else
{ {
@ -75,8 +76,8 @@ std::vector<WellPathCellIntersectionInfo> RigWellPathIntersectionTools::findCell
while (intersection != intersections.cend()) while (intersection != intersections.cend())
{ {
endPoint = intersection->m_intersectionPoint; endPoint = intersection->m_intersectionPoint;
direction = calculateDirectionInCell(grid, cellIndex, startPoint, endPoint); internalCellLengths = calculateLengthInCell(grid, cellIndex, startPoint, endPoint);
intersectionInfo.push_back(WellPathCellIntersectionInfo(cellIndex, direction, startPoint, endPoint)); intersectionInfo.push_back(WellPathCellIntersectionInfo(cellIndex, startPoint, endPoint, internalCellLengths));
startPoint = endPoint; startPoint = endPoint;
cellIndex = intersection->m_hexIndex; cellIndex = intersection->m_hexIndex;
@ -86,8 +87,8 @@ std::vector<WellPathCellIntersectionInfo> RigWellPathIntersectionTools::findCell
if (includeEndCell) if (includeEndCell)
{ {
endPoint = coords[coords.size() - 1]; endPoint = coords[coords.size() - 1];
direction = calculateDirectionInCell(grid, cellIndex, startPoint, endPoint); internalCellLengths = calculateLengthInCell(grid, cellIndex, startPoint, endPoint);
intersectionInfo.push_back(WellPathCellIntersectionInfo(cellIndex, direction, startPoint, endPoint)); intersectionInfo.push_back(WellPathCellIntersectionInfo(cellIndex, startPoint, endPoint, internalCellLengths));
} }
return intersectionInfo; return intersectionInfo;
@ -124,107 +125,35 @@ std::vector<HexIntersectionInfo> RigWellPathIntersectionTools::getIntersectedCel
return intersections; 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 vec = endPoint - startPoint;
cvf::Vec3d iAxisDirection;
cvf::Vec3d jAxisDirection;
cvf::Vec3d kAxisDirection;
cvf::Vec3d iAxisVector; RigCellGeometryTools::findCellLocalXYZ(hexCorners, iAxisDirection, jAxisDirection, kAxisDirection);
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();
cvf::Mat3d localCellCoordinateSystem(iAxisDirection.x(), jAxisDirection.x(), kAxisDirection.x(), cvf::Mat3d localCellCoordinateSystem(iAxisDirection.x(), jAxisDirection.x(), kAxisDirection.x(),
iAxisDirection.y(), jAxisDirection.y(), kAxisDirection.y(), iAxisDirection.y(), jAxisDirection.y(), kAxisDirection.y(),
iAxisDirection.z(), jAxisDirection.z(), kAxisDirection.z()); iAxisDirection.z(), jAxisDirection.z(), kAxisDirection.z());
cvf::Vec3d localCellCoordinateVec = vec.getTransformedVector(localCellCoordinateSystem.getInverted()); return 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;
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
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); std::array<cvf::Vec3d, 8> hexCorners = getCellHexCorners(grid, cellIndex);
return calculateDirectionInCell(hexCorners, startPoint, endPoint); return calculateLengthInCell(hexCorners, startPoint, endPoint);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -30,33 +30,21 @@ class RigWellPath;
class RigMainGrid; class RigMainGrid;
class RigEclipseCaseData; class RigEclipseCaseData;
//==================================================================================================
///
//==================================================================================================
enum WellPathCellDirection {
POS_I,
NEG_I,
POS_J,
NEG_J,
POS_K,
NEG_K
};
//================================================================================================== //==================================================================================================
/// ///
//================================================================================================== //==================================================================================================
struct WellPathCellIntersectionInfo { 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), : cellIndex(cellIndex),
direction(direction),
startPoint(startPoint), startPoint(startPoint),
endPoint(endPoint) endPoint(endPoint),
internalCellLengths(internalCellLengths)
{} {}
size_t cellIndex; size_t cellIndex;
WellPathCellDirection direction; cvf::Vec3d startPoint;
cvf::Vec3d startPoint; cvf::Vec3d endPoint;
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); static std::vector<HexIntersectionInfo> getIntersectedCells(const RigMainGrid* grid, const std::vector<cvf::Vec3d>& coords);
// Calculate direction static cvf::Vec3d calculateLengthInCell(const std::array<cvf::Vec3d, 8>& hexCorners, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint);
static void calculateCellMainAxisVectors(const std::array<cvf::Vec3d, 8>& hexCorners, cvf::Vec3d* iAxisDirection, cvf::Vec3d* jAxisDirection, cvf::Vec3d* kAxisDirection); static cvf::Vec3d calculateLengthInCell(const RigMainGrid* grid, size_t cellIndex, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint);
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 std::vector<size_t> findCloseCells(const RigMainGrid* grid, const cvf::BoundingBox& bb); 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); static size_t findCellFromCoords(const RigMainGrid* caseData, const cvf::Vec3d& coords, bool* foundCell);

View File

@ -22,119 +22,3 @@
#include "cvfStructGrid.h" #include "cvfStructGrid.h"
TEST(RigWellPathIntersectionTools, TestCalculateMainAxisVector)
{
std::array<cvf::Vec3d, 8> hexCorners = {
cvf::Vec3d(0.0, 0.0, 0.0),
cvf::Vec3d(10.0, 0.0, 0.0),
cvf::Vec3d(10.0, 10.0, 0.0),
cvf::Vec3d(0.0, 10.0, 0.0),
cvf::Vec3d(0.0, 0.0, 10.0),
cvf::Vec3d(10.0, 0.0, 10.0),
cvf::Vec3d(10.0, 10.0, 10.0),
cvf::Vec3d(0.0, 10.0, 10.0),
};
cvf::Vec3d iMainAxisVector = RigWellPathIntersectionTools::calculateCellMainAxisVector(hexCorners, cvf::StructGridInterface::NEG_I, cvf::StructGridInterface::POS_I);
EXPECT_EQ(10, iMainAxisVector.x());
EXPECT_EQ(0, iMainAxisVector.y());
EXPECT_EQ(0, iMainAxisVector.z());
cvf::Vec3d jMainAxisVector = RigWellPathIntersectionTools::calculateCellMainAxisVector(hexCorners, cvf::StructGridInterface::NEG_J, cvf::StructGridInterface::POS_J);
EXPECT_EQ(0 , jMainAxisVector.x());
EXPECT_EQ(10, jMainAxisVector.y());
EXPECT_EQ(0, jMainAxisVector.z());
cvf::Vec3d kMainAxisVector = RigWellPathIntersectionTools::calculateCellMainAxisVector(hexCorners, cvf::StructGridInterface::NEG_K, cvf::StructGridInterface::POS_K);
EXPECT_EQ(0, kMainAxisVector.x());
EXPECT_EQ(0, kMainAxisVector.y());
EXPECT_EQ(10, kMainAxisVector.z());
}
TEST(RigWellPathIntersectionTools, TestCalculateMainAxisVectors)
{
std::array<cvf::Vec3d, 8> hexCorners = {
cvf::Vec3d(0.0, 0.0, 0.0),
cvf::Vec3d(10.0, 0.0, 0.0),
cvf::Vec3d(10.0, 10.0, 0.0),
cvf::Vec3d(0.0, 10.0, 0.0),
cvf::Vec3d(0.0, 0.0, 10.0),
cvf::Vec3d(10.0, 0.0, 10.0),
cvf::Vec3d(10.0, 10.0, 10.0),
cvf::Vec3d(0.0, 10.0, 10.0),
};
cvf::Vec3d iMainAxisVector;
cvf::Vec3d jMainAxisVector;
cvf::Vec3d kMainAxisVector;
RigWellPathIntersectionTools::calculateCellMainAxisVectors(hexCorners, &iMainAxisVector, &jMainAxisVector, &kMainAxisVector);
EXPECT_EQ(10, iMainAxisVector.x());
EXPECT_EQ(0, iMainAxisVector.y());
EXPECT_EQ(0, iMainAxisVector.z());
EXPECT_EQ(0 , jMainAxisVector.x());
EXPECT_EQ(10, jMainAxisVector.y());
EXPECT_EQ(0, jMainAxisVector.z());
EXPECT_EQ(0, kMainAxisVector.x());
EXPECT_EQ(0, kMainAxisVector.y());
EXPECT_EQ(10, kMainAxisVector.z());
}
TEST(RigWellPathIntersectionTools, TestCalculateDirectionInCellThroughCellCenters)
{
std::array<cvf::Vec3d, 8> hexCorners = {
cvf::Vec3d(0.0, 0.0, 0.0),
cvf::Vec3d(10.0, 0.0, 0.0),
cvf::Vec3d(10.0, 10.0, 0.0),
cvf::Vec3d(0.0, 10.0, 0.0),
cvf::Vec3d(0.0, 0.0, 10.0),
cvf::Vec3d(10.0, 0.0, 10.0),
cvf::Vec3d(10.0, 10.0, 10.0),
cvf::Vec3d(0.0, 10.0, 10.0),
};
{
cvf::Vec3d startPoint(0, 5, 5);
cvf::Vec3d endPoint(10, 5, 5);
WellPathCellDirection direction = RigWellPathIntersectionTools::calculateDirectionInCell(hexCorners, startPoint, endPoint);
EXPECT_EQ(POS_I, direction);
}
{
cvf::Vec3d startPoint(5, 0, 5);
cvf::Vec3d endPoint(5, 10, 5);
WellPathCellDirection direction = RigWellPathIntersectionTools::calculateDirectionInCell(hexCorners, startPoint, endPoint);
EXPECT_EQ(POS_J, direction);
}
{
cvf::Vec3d startPoint(5, 5, 0);
cvf::Vec3d endPoint(5, 5, 10);
WellPathCellDirection direction = RigWellPathIntersectionTools::calculateDirectionInCell(hexCorners, startPoint, endPoint);
EXPECT_EQ(POS_K, direction);
}
}
TEST(RigWellPathIntersectionTools, TestCalculateJDirectionThroughCells)
{
std::array<cvf::Vec3d, 8> hexCorners = {
cvf::Vec3d(402380, 7.21315e+06, -4219.43),
cvf::Vec3d(402475, 7.21311e+06, -4226.57),
cvf::Vec3d(402510, 7.2132e+06, -4226.75),
cvf::Vec3d(402414, 7.21324e+06, -4222.8),
cvf::Vec3d(402385, 7.21314e+06, -4232.71),
cvf::Vec3d(402480, 7.2131e+06, -4239.88),
cvf::Vec3d(402515, 7.2132e+06, -4239.94),
cvf::Vec3d(402419, 7.21323e+06, -4235.84),
};
cvf::Vec3d startPoint(402428, 7.21323e+06, -4223.35);
cvf::Vec3d endPoint(402399, 7.21314e+06, -4224.48);
WellPathCellDirection direction = RigWellPathIntersectionTools::calculateDirectionInCell(hexCorners, startPoint, endPoint);
EXPECT_EQ(NEG_J, direction);
}