mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Updates to make well path creation intersection work better with GeoMech
This commit is contained in:
parent
107a4b9b60
commit
e689b7ceaf
@ -118,7 +118,6 @@ bool RicCreateWellTargetsPickEventHandler::handlePickEvent(const Ric3DPickEvent&
|
|||||||
cvf::Vec3d domainRayEnd = targetPointInDomain + (targetPointInDomain - domainRayOrigin);
|
cvf::Vec3d domainRayEnd = targetPointInDomain + (targetPointInDomain - domainRayOrigin);
|
||||||
|
|
||||||
cvf::Vec3d hexElementIntersection = findHexElementIntersection(rimView, firstPickItem, domainRayOrigin, domainRayEnd);
|
cvf::Vec3d hexElementIntersection = findHexElementIntersection(rimView, firstPickItem, domainRayOrigin, domainRayEnd);
|
||||||
CVF_ASSERT(!hexElementIntersection.isUndefined());
|
|
||||||
if (!hexElementIntersection.isUndefined())
|
if (!hexElementIntersection.isUndefined())
|
||||||
{
|
{
|
||||||
targetPointInDomain = hexElementIntersection;
|
targetPointInDomain = hexElementIntersection;
|
||||||
@ -232,7 +231,6 @@ cvf::Vec3d RicCreateWellTargetsPickEventHandler::findHexElementIntersection(Rim3
|
|||||||
|
|
||||||
size_t cellIndex = cvf::UNDEFINED_SIZE_T;
|
size_t cellIndex = cvf::UNDEFINED_SIZE_T;
|
||||||
std::array<cvf::Vec3d, 8> cornerVertices;
|
std::array<cvf::Vec3d, 8> cornerVertices;
|
||||||
double characteristicLength = 0.0;
|
|
||||||
if (sourceInfo)
|
if (sourceInfo)
|
||||||
{
|
{
|
||||||
size_t gridIndex = sourceInfo->gridIndex();
|
size_t gridIndex = sourceInfo->gridIndex();
|
||||||
@ -247,7 +245,6 @@ cvf::Vec3d RicCreateWellTargetsPickEventHandler::findHexElementIntersection(Rim3
|
|||||||
hitGrid->cellCornerVertices(cellIndex, cornerVertices.data());
|
hitGrid->cellCornerVertices(cellIndex, cornerVertices.data());
|
||||||
double dx, dy, dz;
|
double dx, dy, dz;
|
||||||
hitGrid->characteristicCellSizes(&dx, &dy, &dz);
|
hitGrid->characteristicCellSizes(&dx, &dy, &dz);
|
||||||
characteristicLength = dz;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,35 +258,39 @@ cvf::Vec3d RicCreateWellTargetsPickEventHandler::findHexElementIntersection(Rim3
|
|||||||
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>(view);
|
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>(view);
|
||||||
if (geoMechView && geoMechView->femParts())
|
if (geoMechView && geoMechView->femParts())
|
||||||
{
|
{
|
||||||
RigFemPart* femPart = geoMechView->femParts()->part(femPartIndex);
|
RigFemPart* femPart = geoMechView->femParts()->part(femPartIndex);
|
||||||
if (femPart->elementType(cellIndex) == HEX8 || femPart->elementType(cellIndex) == HEX8P)
|
RigElementType elType = femPart->elementType(elementIndex);
|
||||||
|
|
||||||
|
if (elType == HEX8 || elType == HEX8P)
|
||||||
{
|
{
|
||||||
cellIndex = elementIndex;
|
cellIndex = elementIndex;
|
||||||
femPart->getOrCreateStructGrid()->cellCornerVertices(cellIndex, cornerVertices.data());
|
const RigFemPartGrid* femGrid = femPart->getOrCreateStructGrid();
|
||||||
characteristicLength = femPart->characteristicElementSize();
|
femGrid->cellCornerVertices(cellIndex, cornerVertices.data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<HexIntersectionInfo> intersectionInfo;
|
if (cellIndex)
|
||||||
RigHexIntersectionTools::lineHexCellIntersection(domainRayOrigin, domainRayEnd, cornerVertices.data(), cellIndex, &intersectionInfo);
|
|
||||||
if (!intersectionInfo.empty())
|
|
||||||
{
|
{
|
||||||
// Sort intersection on distance to ray origin
|
std::vector<HexIntersectionInfo> intersectionInfo;
|
||||||
CVF_ASSERT(intersectionInfo.size() > 1);
|
RigHexIntersectionTools::lineHexCellIntersection(domainRayOrigin, domainRayEnd, cornerVertices.data(), cellIndex, &intersectionInfo);
|
||||||
std::sort(intersectionInfo.begin(), intersectionInfo.end(),
|
if (!intersectionInfo.empty())
|
||||||
[&domainRayOrigin](const HexIntersectionInfo& lhs, const HexIntersectionInfo& rhs)
|
{
|
||||||
|
// Sort intersection on distance to ray origin
|
||||||
|
CVF_ASSERT(intersectionInfo.size() > 1);
|
||||||
|
std::sort(intersectionInfo.begin(), intersectionInfo.end(),
|
||||||
|
[&domainRayOrigin](const HexIntersectionInfo& lhs, const HexIntersectionInfo& rhs)
|
||||||
{
|
{
|
||||||
return (lhs.m_intersectionPoint - domainRayOrigin).lengthSquared() < (rhs.m_intersectionPoint - domainRayOrigin).lengthSquared();
|
return (lhs.m_intersectionPoint - domainRayOrigin).lengthSquared() < (rhs.m_intersectionPoint - domainRayOrigin).lengthSquared();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const double eps = 1.0e-3;
|
const double eps = 1.0e-3;
|
||||||
cvf::Vec3d intersectionRay = intersectionInfo.back().m_intersectionPoint - intersectionInfo.front().m_intersectionPoint;
|
cvf::Vec3d intersectionRay = intersectionInfo.back().m_intersectionPoint - intersectionInfo.front().m_intersectionPoint;
|
||||||
cvf::Vec3d newPoint = intersectionInfo.front().m_intersectionPoint + intersectionRay * eps;
|
cvf::Vec3d newPoint = intersectionInfo.front().m_intersectionPoint + intersectionRay * eps;
|
||||||
CVF_ASSERT(RigHexIntersectionTools::isPointInCell(newPoint, cornerVertices.data()));
|
CVF_ASSERT(RigHexIntersectionTools::isPointInCell(newPoint, cornerVertices.data()));
|
||||||
return newPoint;
|
return newPoint;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cvf::Vec3d::UNDEFINED;
|
return cvf::Vec3d::UNDEFINED;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user