mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Created a common baseclass to be able to use same intersection cleanup code.
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
//==================================================================================================
|
||||
|
||||
RigEclipseWellLogExtractor::RigEclipseWellLogExtractor(const RigCaseData* aCase, const RigWellPath* wellpath)
|
||||
: m_caseData(aCase), m_wellPath(wellpath)
|
||||
: m_caseData(aCase), RigWellLogExtractor(wellpath)
|
||||
{
|
||||
calculateIntersection();
|
||||
}
|
||||
@@ -50,6 +50,8 @@ void RigEclipseWellLogExtractor::calculateIntersection()
|
||||
|
||||
if (!m_wellPath->m_wellPathPoints.size()) return ;
|
||||
|
||||
std::map<RigMDCellIdxEnterLeaveIntersectionSorterKey, HexIntersectionInfo > uniqueIntersections;
|
||||
|
||||
for (size_t wpp = 0; wpp < m_wellPath->m_wellPathPoints.size() - 1; ++wpp)
|
||||
{
|
||||
cvf::BoundingBox bb;
|
||||
@@ -83,8 +85,8 @@ void RigEclipseWellLogExtractor::calculateIntersection()
|
||||
// Now, with all the intersections of this piece of line, we need to
|
||||
// sort them in order, and set the measured depth and corresponding cell index
|
||||
|
||||
// map <WellPathDepthPoint, (CellIdx, intersectionPoint)>
|
||||
std::map<WellPathDepthPoint, HexIntersectionInfo > sortedIntersections;
|
||||
// Inserting the intersections in this map will remove identical intersections
|
||||
// and sort them according to MD, CellIdx, Leave/enter
|
||||
|
||||
double md1 = m_wellPath->m_measuredDepths[wpp];
|
||||
double md2 = m_wellPath->m_measuredDepths[wpp+1];
|
||||
@@ -92,11 +94,13 @@ void RigEclipseWellLogExtractor::calculateIntersection()
|
||||
for (size_t intIdx = 0; intIdx < intersections.size(); ++intIdx)
|
||||
{
|
||||
if (!isCellFaceNormalsOut) intersections[intIdx].m_isIntersectionEntering = !intersections[intIdx].m_isIntersectionEntering ;
|
||||
|
||||
double lenghtAlongLineSegment1 = (intersections[intIdx].m_intersectionPoint - p1).length();
|
||||
double lenghtAlongLineSegment2 = (p2 - intersections[intIdx].m_intersectionPoint).length();
|
||||
double measuredDepthDiff = md2 - md1;
|
||||
double lineLength = lenghtAlongLineSegment1 + lenghtAlongLineSegment2;
|
||||
double measuredDepthOfPoint = 0.0;
|
||||
double measuredDepthDiff = md2 - md1;
|
||||
double lineLength = lenghtAlongLineSegment1 + lenghtAlongLineSegment2;
|
||||
double measuredDepthOfPoint = 0.0;
|
||||
|
||||
if (lineLength > 0.00001)
|
||||
{
|
||||
measuredDepthOfPoint = md1 + measuredDepthDiff*lenghtAlongLineSegment1/(lineLength);
|
||||
@@ -105,14 +109,125 @@ void RigEclipseWellLogExtractor::calculateIntersection()
|
||||
{
|
||||
measuredDepthOfPoint = md1;
|
||||
}
|
||||
sortedIntersections.insert(std::make_pair(WellPathDepthPoint(measuredDepthOfPoint, intersections[intIdx].m_isIntersectionEntering), intersections[intIdx]));
|
||||
|
||||
uniqueIntersections.insert(std::make_pair(RigMDCellIdxEnterLeaveIntersectionSorterKey(measuredDepthOfPoint,
|
||||
intersections[intIdx].m_hexIndex,
|
||||
intersections[intIdx].m_isIntersectionEntering),
|
||||
intersections[intIdx]));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// For same MD and same cell, remove enter/leave pairs, as they only touches the wellpath, and should not contribute.
|
||||
|
||||
std::map<RigMDCellIdxEnterLeaveIntersectionSorterKey, HexIntersectionInfo >::iterator it1 = uniqueIntersections.begin();
|
||||
std::map<RigMDCellIdxEnterLeaveIntersectionSorterKey, HexIntersectionInfo >::iterator it2 = uniqueIntersections.begin();
|
||||
|
||||
std::vector<std::map<RigMDCellIdxEnterLeaveIntersectionSorterKey, HexIntersectionInfo >::iterator> iteratorsToIntersectonsToErase;
|
||||
|
||||
while (it2 != uniqueIntersections.end())
|
||||
{
|
||||
++it2;
|
||||
if (it2 != uniqueIntersections.end())
|
||||
{
|
||||
if (RigHexIntersector::isEqualDepth(it1->first.measuredDepth, it2->first.measuredDepth))
|
||||
{
|
||||
if (it1->first.hexIndex == it2->first.hexIndex)
|
||||
{
|
||||
// Remove the two from the map, as they just are a touch of the cell surface
|
||||
CVF_TIGHT_ASSERT(!it1->first.isEnteringCell && it2->first.isEnteringCell);
|
||||
|
||||
iteratorsToIntersectonsToErase.push_back(it1);
|
||||
iteratorsToIntersectonsToErase.push_back(it2);
|
||||
}
|
||||
}
|
||||
}
|
||||
++it1;
|
||||
}
|
||||
|
||||
// Now populate the return arrays
|
||||
// Erase all the intersections that is not needed
|
||||
for (size_t erItIdx = 0; erItIdx < iteratorsToIntersectonsToErase.size(); ++erItIdx)
|
||||
{
|
||||
uniqueIntersections.erase(iteratorsToIntersectonsToErase[erItIdx]);
|
||||
}
|
||||
}
|
||||
|
||||
std::map<WellPathDepthPoint, HexIntersectionInfo >::iterator it;
|
||||
it = sortedIntersections.begin();
|
||||
while (it != sortedIntersections.end())
|
||||
// Copy the map into a different sorting regime, with enter leave more significant than cell index
|
||||
std::map<RigMDEnterLeaveCellIdxIntersectionSorterKey, HexIntersectionInfo > sortedUniqueIntersections;
|
||||
{
|
||||
std::map<RigMDCellIdxEnterLeaveIntersectionSorterKey, HexIntersectionInfo >::iterator it = uniqueIntersections.begin();
|
||||
while (it != uniqueIntersections.end())
|
||||
{
|
||||
sortedUniqueIntersections.insert(std::make_pair(RigMDEnterLeaveCellIdxIntersectionSorterKey(it->first.measuredDepth, it->first.isEnteringCell, it->first.hexIndex),
|
||||
it->second));
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Make sure we have sensible pairs of intersections. One pair for each in/out of a cell
|
||||
{
|
||||
// Add an intersection for the well startpoint that is inside the first cell
|
||||
std::map<RigMDEnterLeaveCellIdxIntersectionSorterKey, HexIntersectionInfo >::iterator it = sortedUniqueIntersections.begin();
|
||||
if (it != sortedUniqueIntersections.end() && !it->first.isEnteringCell) // Leaving a cell as first intersection. Well starts inside a cell.
|
||||
{
|
||||
// Needs wellpath start point in front
|
||||
HexIntersectionInfo firstLeavingPoint = it->second;
|
||||
firstLeavingPoint.m_intersectionPoint = m_wellPath->m_wellPathPoints[0];
|
||||
|
||||
sortedUniqueIntersections.insert(std::make_pair(RigMDEnterLeaveCellIdxIntersectionSorterKey(m_wellPath->m_measuredDepths[0], firstLeavingPoint.m_hexIndex, true),
|
||||
firstLeavingPoint));
|
||||
}
|
||||
|
||||
// Add an intersection for the well endpoint possibly inside the last cell.
|
||||
std::map<RigMDEnterLeaveCellIdxIntersectionSorterKey, HexIntersectionInfo >::reverse_iterator rit = sortedUniqueIntersections.rbegin();
|
||||
if (rit != sortedUniqueIntersections.rend() && rit->first.isEnteringCell) // Entering a cell as last intersection. Well ends inside a cell.
|
||||
{
|
||||
// Needs wellpath end point at end
|
||||
HexIntersectionInfo lastEnterPoint = rit->second;
|
||||
lastEnterPoint.m_intersectionPoint = m_wellPath->m_wellPathPoints.back();
|
||||
|
||||
sortedUniqueIntersections.insert(std::make_pair(RigMDEnterLeaveCellIdxIntersectionSorterKey(m_wellPath->m_measuredDepths.back(), lastEnterPoint.m_hexIndex, false),
|
||||
lastEnterPoint));
|
||||
}
|
||||
}
|
||||
|
||||
std::map<RigMDEnterLeaveIntersectionSorterKey, HexIntersectionInfo > filteredSortedIntersections;
|
||||
|
||||
{
|
||||
std::map<RigMDEnterLeaveCellIdxIntersectionSorterKey, HexIntersectionInfo >::iterator it1 = sortedUniqueIntersections.begin();
|
||||
std::map<RigMDEnterLeaveCellIdxIntersectionSorterKey, HexIntersectionInfo >::iterator it2;
|
||||
|
||||
while (it1 != sortedUniqueIntersections.end())
|
||||
{
|
||||
it2 = it1;
|
||||
++it2;
|
||||
|
||||
if (it2 == sortedUniqueIntersections.end()) break;
|
||||
|
||||
// If we have a proper pair, insert in the filtered list and continue
|
||||
if ( !RigMDEnterLeaveCellIdxIntersectionSorterKey::isProperPair( it1->first, it2->first))
|
||||
{
|
||||
//CVF_ASSERT(false);
|
||||
cvf::Trace::show(cvf::String("Well log curve is inaccurate around MD: ") + cvf::String::number((double)(it1->first.measuredDepth)) + ", " + cvf::String::number((double)(it2->first.measuredDepth)));
|
||||
}
|
||||
{
|
||||
filteredSortedIntersections.insert(std::make_pair(RigMDEnterLeaveIntersectionSorterKey(it1->first.measuredDepth, it1->first.isEnteringCell),
|
||||
it1->second));
|
||||
++it1;
|
||||
filteredSortedIntersections.insert(std::make_pair(RigMDEnterLeaveIntersectionSorterKey(it1->first.measuredDepth, it1->first.isEnteringCell),
|
||||
it1->second));
|
||||
++it1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// Now populate the return arrays
|
||||
std::map<RigMDEnterLeaveIntersectionSorterKey, HexIntersectionInfo >::iterator it;
|
||||
|
||||
it = filteredSortedIntersections.begin();
|
||||
while (it != filteredSortedIntersections.end())
|
||||
{
|
||||
m_measuredDepth.push_back(it->first.measuredDepth);
|
||||
m_trueVerticalDepth.push_back(abs(it->second.m_intersectionPoint[2]));
|
||||
@@ -130,7 +245,7 @@ void RigEclipseWellLogExtractor::calculateIntersection()
|
||||
void RigEclipseWellLogExtractor::curveData(const RigResultAccessor* resultAccessor, std::vector<double>* values)
|
||||
{
|
||||
CVF_TIGHT_ASSERT(values);
|
||||
values->resize(m_intersections.size());// + 1); // Plus one for the end of the wellpath stopping inside a cell
|
||||
values->resize(m_intersections.size());
|
||||
|
||||
for (size_t cpIdx = 0; cpIdx < m_intersections.size(); ++cpIdx)
|
||||
{
|
||||
@@ -138,9 +253,7 @@ void RigEclipseWellLogExtractor::curveData(const RigResultAccessor* resultAccess
|
||||
cvf::StructGridInterface::FaceType cellFace = m_intersectedCellFaces[cpIdx];
|
||||
(*values)[cpIdx] = resultAccessor->cellFaceScalarGlobIdx(cellIdx, cellFace);
|
||||
}
|
||||
|
||||
// What do we do with the endpoint of the wellpath ?
|
||||
// Ignore it for now ...
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user