2015-09-04 08:30:04 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) Statoil ASA
|
|
|
|
// Copyright (C) Ceetron Solutions AS
|
|
|
|
//
|
|
|
|
// 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
|
2017-06-14 07:34:52 -05:00
|
|
|
#include <cmath>
|
2015-09-04 08:30:04 -05:00
|
|
|
|
|
|
|
//==================================================================================================
|
2017-06-14 07:15:29 -05:00
|
|
|
///
|
|
|
|
///
|
2015-09-04 08:30:04 -05:00
|
|
|
//==================================================================================================
|
|
|
|
|
2017-06-14 07:15:29 -05:00
|
|
|
struct RigWellLogExtractionTools
|
2015-09-04 08:30:04 -05:00
|
|
|
{
|
2017-06-14 07:15:29 -05:00
|
|
|
static bool isEqualDepth(double d1, double d2)
|
2017-05-15 08:49:49 -05:00
|
|
|
{
|
2015-10-14 01:08:13 -05:00
|
|
|
double depthDiff = d1 - d2;
|
|
|
|
|
|
|
|
const double tolerance = 0.1;// Meters To handle inaccuracies across faults
|
|
|
|
|
|
|
|
return (fabs(depthDiff) < tolerance); // Equal depth
|
|
|
|
}
|
2015-09-04 08:30:04 -05:00
|
|
|
};
|
|
|
|
|
2015-10-14 01:08:13 -05:00
|
|
|
//==================================================================================================
|
|
|
|
/// Class used to sort the intersections along the wellpath,
|
|
|
|
/// Use as key in a map
|
|
|
|
/// Sorting according to MD first, then Cell Idx, then Leaving before entering cell
|
|
|
|
//==================================================================================================
|
|
|
|
|
2015-10-14 05:40:31 -05:00
|
|
|
struct RigMDCellIdxEnterLeaveKey
|
2015-10-14 01:08:13 -05:00
|
|
|
{
|
2018-02-23 15:38:08 -06:00
|
|
|
RigMDCellIdxEnterLeaveKey(double md, size_t cellIdx, bool entering)
|
|
|
|
: measuredDepth(md)
|
|
|
|
, hexIndex(cellIdx)
|
|
|
|
, isEnteringCell(entering)
|
|
|
|
{
|
|
|
|
}
|
2015-10-14 01:08:13 -05:00
|
|
|
|
|
|
|
double measuredDepth;
|
|
|
|
size_t hexIndex;
|
|
|
|
bool isEnteringCell; // As opposed to leaving.
|
|
|
|
bool isLeavingCell() const { return !isEnteringCell;}
|
|
|
|
|
2015-10-14 05:40:31 -05:00
|
|
|
bool operator < (const RigMDCellIdxEnterLeaveKey& other) const
|
2015-10-14 01:08:13 -05:00
|
|
|
{
|
2017-06-14 07:15:29 -05:00
|
|
|
if (RigWellLogExtractionTools::isEqualDepth(measuredDepth, other.measuredDepth))
|
2015-09-04 08:30:04 -05:00
|
|
|
{
|
2015-10-14 01:08:13 -05:00
|
|
|
if (hexIndex == other.hexIndex)
|
|
|
|
{
|
|
|
|
if (isEnteringCell == other.isEnteringCell)
|
|
|
|
{
|
|
|
|
// Completely equal: intersections at cell edges or corners or edges of the face triangles
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return !isEnteringCell; // Sort Leaving cell before (less than) entering cell
|
|
|
|
}
|
|
|
|
|
|
|
|
return (hexIndex < other.hexIndex);
|
2015-09-04 08:30:04 -05:00
|
|
|
}
|
2015-10-14 01:08:13 -05:00
|
|
|
|
|
|
|
// The depths are not equal
|
|
|
|
|
|
|
|
return (measuredDepth < other.measuredDepth);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
/// Class used to sort the intersections along the wellpath,
|
|
|
|
/// Use as key in a map
|
|
|
|
/// Sorting according to MD first,then Leaving before entering cell, then Cell Idx,
|
|
|
|
//==================================================================================================
|
|
|
|
|
2015-10-14 05:40:31 -05:00
|
|
|
struct RigMDEnterLeaveCellIdxKey
|
2015-10-14 01:08:13 -05:00
|
|
|
{
|
2018-02-23 15:38:08 -06:00
|
|
|
RigMDEnterLeaveCellIdxKey(double md, bool entering, size_t cellIdx)
|
|
|
|
: measuredDepth(md)
|
|
|
|
, isEnteringCell(entering)
|
|
|
|
, hexIndex(cellIdx)
|
|
|
|
{
|
|
|
|
}
|
2015-10-14 01:08:13 -05:00
|
|
|
|
|
|
|
double measuredDepth;
|
|
|
|
bool isEnteringCell; // As opposed to leaving.
|
|
|
|
bool isLeavingCell() const { return !isEnteringCell;}
|
|
|
|
size_t hexIndex;
|
|
|
|
|
2015-10-14 05:40:31 -05:00
|
|
|
bool operator < (const RigMDEnterLeaveCellIdxKey& other) const
|
2015-10-14 01:08:13 -05:00
|
|
|
{
|
2017-06-14 07:15:29 -05:00
|
|
|
if (RigWellLogExtractionTools::isEqualDepth(measuredDepth, other.measuredDepth))
|
2015-09-04 08:30:04 -05:00
|
|
|
{
|
2015-10-14 01:08:13 -05:00
|
|
|
if (isEnteringCell == other.isEnteringCell)
|
|
|
|
{
|
|
|
|
if (hexIndex == other.hexIndex)
|
|
|
|
{
|
|
|
|
// Completely equal: intersections at cell edges or corners or edges of the face triangles
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (hexIndex < other.hexIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
return isLeavingCell(); // Sort Leaving cell before (less than) entering cell
|
2015-09-04 08:30:04 -05:00
|
|
|
}
|
|
|
|
|
2015-10-14 01:08:13 -05:00
|
|
|
// The depths are not equal
|
|
|
|
|
|
|
|
return (measuredDepth < other.measuredDepth);
|
|
|
|
}
|
|
|
|
|
2015-10-14 08:07:48 -05:00
|
|
|
static bool isProperCellEnterLeavePair(const RigMDEnterLeaveCellIdxKey& key1, const RigMDEnterLeaveCellIdxKey& key2 )
|
2015-10-14 01:08:13 -05:00
|
|
|
{
|
|
|
|
return ( key1.hexIndex == key2.hexIndex
|
|
|
|
&& key1.isEnteringCell && key2.isLeavingCell()
|
2017-06-14 07:15:29 -05:00
|
|
|
&& !RigWellLogExtractionTools::isEqualDepth(key1.measuredDepth, key2.measuredDepth));
|
2015-09-04 08:30:04 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|