#2569 Fracture containment. Fix fracture border polygon calculation

This commit is contained in:
Bjørn Erik Jensen
2018-03-08 11:01:04 +01:00
parent 0629551fa8
commit 6942a99406
8 changed files with 70 additions and 94 deletions

View File

@@ -455,6 +455,43 @@ double RigCellGeometryTools::getLengthOfPolygonAlongLine(const std::pair<cvf::Ve
return length;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RigCellGeometryTools::unionOfPolygons(std::vector<std::vector<cvf::Vec3d>> polygons)
{
// Convert to int for clipper library and store as clipper "path"
std::vector<ClipperLib::Path> polygonPaths;
for (const std::vector<cvf::Vec3d>& polygon : polygons)
{
polygonPaths.emplace_back();
auto& p = polygonPaths.back();
for (const cvf::Vec3d& pp : polygon)
{
p.push_back(toClipperPoint(pp));
}
}
ClipperLib::Clipper clpr;
clpr.AddPaths(polygonPaths, ClipperLib::ptSubject, true);
ClipperLib::Paths solution;
clpr.Execute(ClipperLib::ctUnion, solution, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd);
// Convert back to std::vector<std::vector<cvf::Vec3d> >
std::vector<cvf::Vec3d> unionPolygon;
for (ClipperLib::Path pathInSol : solution)
{
std::vector<cvf::Vec3d> clippedPolygon;
for (ClipperLib::IntPoint IntPosition : pathInSol)
{
unionPolygon.push_back(fromClipperPoint(IntPosition));
}
}
return unionPolygon;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -51,6 +51,8 @@ public:
static double getLengthOfPolygonAlongLine(const std::pair<cvf::Vec3d, cvf::Vec3d>& line, const std::vector<cvf::Vec3d>& polygon);
static std::vector<cvf::Vec3d> unionOfPolygons(std::vector<std::vector<cvf::Vec3d>> polygons);
private:
static std::vector<cvf::Vec3d> ajustPolygonToAvoidIntersectionsAtVertex(const std::vector<cvf::Vec3d>& polyLine,
const std::vector<cvf::Vec3d>& polygon);

View File

@@ -31,7 +31,6 @@
#include <cmath>
//--------------------------------------------------------------------------------------------------
/// Internal functions
//--------------------------------------------------------------------------------------------------
@@ -408,13 +407,13 @@ cvf::ref<RigFractureGrid> RigStimPlanFractureDefinition::createFractureGrid(cons
RiaLogging::error("Did not find stim plan cell at well crossing!");
}
cvf::ref<RigFractureGrid> m_fractureGrid = new RigFractureGrid;
m_fractureGrid->setFractureCells(stimPlanCells);
m_fractureGrid->setWellCenterFractureCellIJ(wellCenterStimPlanCellIJ);
m_fractureGrid->setICellCount(this->m_Xs.size() - 2);
m_fractureGrid->setJCellCount(this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth).size() - 2);
cvf::ref<RigFractureGrid> fractureGrid = new RigFractureGrid;
fractureGrid->setFractureCells(stimPlanCells);
fractureGrid->setWellCenterFractureCellIJ(wellCenterStimPlanCellIJ);
fractureGrid->setICellCount(this->m_Xs.size() - 2);
fractureGrid->setJCellCount(this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth).size() - 2);
return m_fractureGrid;
return fractureGrid;
}
//--------------------------------------------------------------------------------------------------
@@ -526,68 +525,6 @@ void sortPolygon(std::vector<cvf::Vec3f> &polygon)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3f> RigStimPlanFractureDefinition::createFractureBorderPolygon(const QString& resultName,
const QString& resultUnit,
int activeTimeStepIndex,
double wellPathIntersectionAtFractureDepth,
const QString& fractureUserName)
{
std::vector<cvf::Vec3f> polygon;
std::vector<std::vector<double>> dataAtTimeStep = this->getDataAtTimeIndex(resultName, resultUnit, activeTimeStepIndex);
std::vector<double> adjustedYs = this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth);
for ( int k = 0; k < static_cast<int>(dataAtTimeStep.size()); k++ )
{
for ( int i = 0; i < static_cast<int>(dataAtTimeStep[k].size()); i++ )
{
if ( (dataAtTimeStep[k])[i] < 1e-7 ) //polygon should consist of nodes with value 0
{
if ( (i > 0) && ((dataAtTimeStep[k])[(i - 1)] > 1e-7) ) //side neighbour cell different from 0
{
polygon.push_back(cvf::Vec3f(static_cast<float>(this->m_Xs[i]),
static_cast<float>(adjustedYs[k]), 0.0f));
}
else if ( (k < static_cast<int>(dataAtTimeStep.size()) - 1) && ((dataAtTimeStep[k + 1])[(i)] > 1e-7) )//cell below different from 0
{
polygon.push_back(cvf::Vec3f(static_cast<float>(this->m_Xs[i]),
static_cast<float>(adjustedYs[k]), 0.0f));
}
else if ( (k > 0) && ((dataAtTimeStep[k - 1])[(i)] > 1e-7) )//cell above different from 0
{
polygon.push_back(cvf::Vec3f(static_cast<float>(this->m_Xs[i]),
static_cast<float>(adjustedYs[k]), 0.0f));
}
}
}
}
sortPolygon(polygon);
std::vector<cvf::Vec3f> negPolygon;
for ( const cvf::Vec3f& node : polygon )
{
cvf::Vec3f negNode = node;
negNode.x() = -negNode.x();
negPolygon.insert(negPolygon.begin(), negNode);
}
for ( const cvf::Vec3f& negNode : negPolygon )
{
polygon.push_back(negNode);
}
//Adding first point last - to close the polygon
if ( polygon.size()>0 ) polygon.push_back(polygon[0]);
return polygon;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -81,12 +81,6 @@ public:
std::vector<cvf::Vec3f>* vertices,
std::vector<cvf::uint>* triangleIndices);
std::vector<cvf::Vec3f> createFractureBorderPolygon(const QString& resultName,
const QString& resultUnit,
int activeTimeStepIndex,
double wellPathIntersectionAtFractureDepth,
const QString& fractureUserName);
const std::vector<double>& timeSteps() const;
void addTimeStep(double time);
size_t totalNumberTimeSteps();