mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1585 Move geometry generation code frm RimStimPlanTemplate to Rig
This commit is contained in:
parent
d8d2aaed5f
commit
e9b9b17739
@ -375,83 +375,16 @@ void RimStimPlanFractureTemplate::updateFractureGrid()
|
||||
QString resultNameFromColors = activeView->stimPlanColors->resultName();
|
||||
QString resultUnitFromColors = activeView->stimPlanColors->unit();
|
||||
|
||||
std::vector<RigFractureCell> stimPlanCells;
|
||||
std::pair<size_t, size_t> wellCenterStimPlanCellIJ = std::make_pair(0,0);
|
||||
m_fractureGrid = m_stimPlanFractureDefinitionData->createFractureGrid(resultNameFromColors,
|
||||
resultUnitFromColors,
|
||||
m_activeTimeStepIndex,
|
||||
fractureTemplateUnit,
|
||||
m_wellPathDepthAtFracture);
|
||||
|
||||
bool wellCenterStimPlanCellFound = false;
|
||||
|
||||
std::vector<std::vector<double>> displayPropertyValuesAtTimeStep = m_stimPlanFractureDefinitionData->getMirroredDataAtTimeIndex(resultNameFromColors, resultUnitFromColors, m_activeTimeStepIndex);
|
||||
|
||||
QString condUnit;
|
||||
if (fractureTemplateUnit == RimUnitSystem::UNITS_METRIC) condUnit = "md-m";
|
||||
if (fractureTemplateUnit == RimUnitSystem::UNITS_FIELD) condUnit = "md-ft";
|
||||
std::vector<std::vector<double>> conductivityValuesAtTimeStep = m_stimPlanFractureDefinitionData->getMirroredDataAtTimeIndex("CONDUCTIVITY", condUnit, m_activeTimeStepIndex);
|
||||
|
||||
std::vector<double> depthCoordsAtNodes = m_stimPlanFractureDefinitionData->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture());
|
||||
std::vector<double> xCoordsAtNodes = m_stimPlanFractureDefinitionData->getNegAndPosXcoords();
|
||||
|
||||
std::vector<double> xCoords;
|
||||
for (int i = 0; i < xCoordsAtNodes.size() - 1; i++) xCoords.push_back((xCoordsAtNodes[i] + xCoordsAtNodes[i + 1]) / 2);
|
||||
std::vector<double> depthCoords;
|
||||
for (int i = 0; i < depthCoordsAtNodes.size() - 1; i++) depthCoords.push_back((depthCoordsAtNodes[i] + depthCoordsAtNodes[i + 1]) / 2);
|
||||
|
||||
for (int i = 0; i < xCoords.size() - 1; i++)
|
||||
{
|
||||
for (int j = 0; j < depthCoords.size() - 1; j++)
|
||||
{
|
||||
std::vector<cvf::Vec3d> cellPolygon;
|
||||
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i]), static_cast<float>(depthCoords[j]), 0.0));
|
||||
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i + 1]), static_cast<float>(depthCoords[j]), 0.0));
|
||||
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i + 1]), static_cast<float>(depthCoords[j + 1]), 0.0));
|
||||
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i]), static_cast<float>(depthCoords[j + 1]), 0.0));
|
||||
|
||||
RigFractureCell stimPlanCell(cellPolygon, i, j);
|
||||
if (conductivityValuesAtTimeStep.size() > 0) //Assuming vector to be of correct length, or no values
|
||||
{
|
||||
stimPlanCell.setConductivityValue(conductivityValuesAtTimeStep[j + 1][i + 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
stimPlanCell.setConductivityValue(cvf::UNDEFINED_DOUBLE);
|
||||
}
|
||||
|
||||
if (displayPropertyValuesAtTimeStep.size() > 0)
|
||||
{
|
||||
stimPlanCell.setDisplayValue(displayPropertyValuesAtTimeStep[j + 1][i + 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
stimPlanCell.setDisplayValue(cvf::UNDEFINED_DOUBLE);
|
||||
}
|
||||
|
||||
if (cellPolygon[0].x() < 0.0 && cellPolygon[1].x() > 0.0)
|
||||
{
|
||||
if (cellPolygon[1].y() > 0.0 && cellPolygon[2].y() < 0.0)
|
||||
{
|
||||
wellCenterStimPlanCellIJ = std::make_pair(stimPlanCell.getI(), stimPlanCell.getJ());
|
||||
RiaLogging::debug(QString("Setting wellCenterStimPlanCell at cell %1, %2").
|
||||
arg(QString::number(stimPlanCell.getI()), QString::number(stimPlanCell.getJ())));
|
||||
|
||||
wellCenterStimPlanCellFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
stimPlanCells.push_back(stimPlanCell);
|
||||
}
|
||||
}
|
||||
|
||||
if (!wellCenterStimPlanCellFound)
|
||||
{
|
||||
RiaLogging::error("Did not find stim plan cell at well crossing!");
|
||||
}
|
||||
|
||||
m_fractureGrid->setFractureCells(stimPlanCells);
|
||||
m_fractureGrid->setWellCenterFractureCellIJ(wellCenterStimPlanCellIJ);
|
||||
m_fractureGrid->setICellCount(m_stimPlanFractureDefinitionData->getNegAndPosXcoords().size() - 2);
|
||||
m_fractureGrid->setJCellCount(m_stimPlanFractureDefinitionData->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture()).size() - 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -465,198 +398,31 @@ void RimStimPlanFractureTemplate::fractureTriangleGeometry(std::vector<cvf::Vec3
|
||||
loadDataAndUpdate();
|
||||
}
|
||||
|
||||
|
||||
std::vector<double> xCoords = m_stimPlanFractureDefinitionData->getNegAndPosXcoords();
|
||||
cvf::uint lenXcoords = static_cast<cvf::uint>(xCoords.size());
|
||||
|
||||
std::vector<double> adjustedDepths = m_stimPlanFractureDefinitionData->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture());
|
||||
|
||||
if (neededUnit == fractureTemplateUnit())
|
||||
{
|
||||
RiaLogging::debug(QString("No conversion necessary for %1").arg(name));
|
||||
}
|
||||
|
||||
else if (fractureTemplateUnit() == RimUnitSystem::UNITS_METRIC && neededUnit == RimUnitSystem::UNITS_FIELD)
|
||||
{
|
||||
RiaLogging::info(QString("Converting StimPlan geometry from metric to field for fracture template %1").arg(name));
|
||||
for (double& value : adjustedDepths) value = RimUnitSystem::meterToFeet(value);
|
||||
for (double& value : xCoords) value = RimUnitSystem::meterToFeet(value);
|
||||
}
|
||||
else if (fractureTemplateUnit() == RimUnitSystem::UNITS_FIELD && neededUnit == RimUnitSystem::UNITS_METRIC)
|
||||
{
|
||||
RiaLogging::info(QString("Converting StimPlan geometry from field to metric for fracture template %1").arg(name));
|
||||
for (double& value : adjustedDepths) value = RimUnitSystem::feetToMeter(value);
|
||||
for (double& value : xCoords) value = RimUnitSystem::feetToMeter(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Should never get here...
|
||||
RiaLogging::error(QString("Error: Could not convert units for fracture template %1").arg(name));
|
||||
return;
|
||||
}
|
||||
|
||||
for (cvf::uint k = 0; k < adjustedDepths.size(); k++)
|
||||
{
|
||||
for (cvf::uint i = 0; i < lenXcoords; i++)
|
||||
{
|
||||
cvf::Vec3f node = cvf::Vec3f(xCoords[i], adjustedDepths[k], 0);
|
||||
nodeCoords->push_back(node);
|
||||
|
||||
if (i < lenXcoords - 1 && k < adjustedDepths.size() - 1)
|
||||
{
|
||||
if (xCoords[i] < 1e-5)
|
||||
{
|
||||
//Upper triangle
|
||||
triangleIndices->push_back(i + k*lenXcoords);
|
||||
triangleIndices->push_back((i + 1) + k*lenXcoords);
|
||||
triangleIndices->push_back((i + 1) + (k + 1)*lenXcoords);
|
||||
//Lower triangle
|
||||
triangleIndices->push_back(i + k*lenXcoords);
|
||||
triangleIndices->push_back((i + 1) + (k + 1)*lenXcoords);
|
||||
triangleIndices->push_back((i)+(k + 1)*lenXcoords);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//Upper triangle
|
||||
triangleIndices->push_back(i + k*lenXcoords);
|
||||
triangleIndices->push_back((i + 1) + k*lenXcoords);
|
||||
triangleIndices->push_back((i)+(k + 1)*lenXcoords);
|
||||
//Lower triangle
|
||||
triangleIndices->push_back((i + 1) + k*lenXcoords);
|
||||
triangleIndices->push_back((i + 1) + (k + 1)*lenXcoords);
|
||||
triangleIndices->push_back((i) + (k + 1)*lenXcoords);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_stimPlanFractureDefinitionData->createFractureTriangleGeometry(m_wellPathDepthAtFracture,
|
||||
neededUnit,
|
||||
name,
|
||||
nodeCoords,
|
||||
triangleIndices);
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::Vec3f> RimStimPlanFractureTemplate::fractureBorderPolygon(RimUnitSystem::UnitSystem fractureUnit)
|
||||
std::vector<cvf::Vec3f> RimStimPlanFractureTemplate::fractureBorderPolygon(RimUnitSystem::UnitSystem neededUnit)
|
||||
{
|
||||
std::vector<cvf::Vec3f> polygon;
|
||||
|
||||
QString parameterName = m_borderPolygonResultName;
|
||||
QString parameterUnit = getUnitForStimPlanParameter(parameterName);
|
||||
|
||||
std::vector<std::vector<double>> dataAtTimeStep = m_stimPlanFractureDefinitionData->getDataAtTimeIndex(parameterName, parameterUnit, m_activeTimeStepIndex);
|
||||
|
||||
std::vector<double> adjustedDepths = m_stimPlanFractureDefinitionData->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture());
|
||||
|
||||
for (int k = 0; k < dataAtTimeStep.size(); k++)
|
||||
{
|
||||
for (int i = 0; i < 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>(m_stimPlanFractureDefinitionData->gridXs[i]),
|
||||
static_cast<float>(adjustedDepths[k]), 0.0f));
|
||||
}
|
||||
else if ((k < dataAtTimeStep.size() - 1) && ((dataAtTimeStep[k + 1])[(i)] > 1e-7))//cell below different from 0
|
||||
{
|
||||
polygon.push_back(cvf::Vec3f(static_cast<float>(m_stimPlanFractureDefinitionData->gridXs[i]),
|
||||
static_cast<float>(adjustedDepths[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>(m_stimPlanFractureDefinitionData->gridXs[i]),
|
||||
static_cast<float>(adjustedDepths[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]);
|
||||
|
||||
|
||||
if (fractureUnit == fractureTemplateUnit())
|
||||
{
|
||||
RiaLogging::debug(QString("No conversion necessary for %1").arg(name));
|
||||
}
|
||||
|
||||
else if (fractureTemplateUnit() == RimUnitSystem::UNITS_METRIC && fractureUnit == RimUnitSystem::UNITS_FIELD)
|
||||
{
|
||||
RiaLogging::info(QString("Converting StimPlan geometry from metric to field for fracture template %1").arg(name));
|
||||
for (cvf::Vec3f& node : polygon)
|
||||
{
|
||||
float x = RimUnitSystem::meterToFeet(node.x());
|
||||
float y = RimUnitSystem::meterToFeet(node.y());
|
||||
float z = RimUnitSystem::meterToFeet(node.z());
|
||||
node = cvf::Vec3f(x, y, z);
|
||||
}
|
||||
}
|
||||
else if (fractureTemplateUnit() == RimUnitSystem::UNITS_FIELD && fractureUnit == RimUnitSystem::UNITS_METRIC)
|
||||
{
|
||||
RiaLogging::info(QString("Converting StimPlan geometry from field to metric for fracture template %1").arg(name));
|
||||
for (cvf::Vec3f& node : polygon)
|
||||
{
|
||||
float x = RimUnitSystem::feetToMeter(node.x());
|
||||
float y = RimUnitSystem::feetToMeter(node.y());
|
||||
float z = RimUnitSystem::feetToMeter(node.z());
|
||||
node = cvf::Vec3f(x, y, z);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Should never get here...
|
||||
RiaLogging::error(QString("Error: Could not convert units for fracture template %1").arg(name));
|
||||
}
|
||||
|
||||
|
||||
return polygon;
|
||||
return m_stimPlanFractureDefinitionData->createFractureBorderPolygon(parameterName,
|
||||
parameterUnit,
|
||||
m_activeTimeStepIndex,
|
||||
m_wellPathDepthAtFracture,
|
||||
neededUnit,
|
||||
name);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStimPlanFractureTemplate::sortPolygon(std::vector<cvf::Vec3f> &polygon)
|
||||
{
|
||||
if (polygon.size() == 0) return;
|
||||
|
||||
for (int i = 1; i < polygon.size() - 1; i++)
|
||||
{
|
||||
cvf::Vec3f lastNode = polygon[i - 1];
|
||||
cvf::Vec3f node = polygon[i];
|
||||
cvf::Vec3f nextNode = polygon[i + 1];
|
||||
|
||||
if (node.y() == nextNode.y())
|
||||
{
|
||||
if (lastNode.x() < node.x() && node.x() > nextNode.x())
|
||||
{
|
||||
polygon[i] = nextNode;
|
||||
polygon[i + 1] = node;
|
||||
}
|
||||
else if (lastNode.x() > node.x() && node.x() < nextNode.x())
|
||||
{
|
||||
polygon[i] = nextNode;
|
||||
polygon[i + 1] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
@ -22,6 +22,9 @@
|
||||
|
||||
#include "cvfMath.h"
|
||||
#include "RivWellFracturePartMgr.h"
|
||||
#include "RigFractureCell.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RigFractureGrid.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -65,6 +68,288 @@ std::vector<std::vector<double>> RigStimPlanFractureDefinition::getMirroredDataA
|
||||
return mirroredData;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RigFractureGrid> RigStimPlanFractureDefinition::createFractureGrid(const QString& resultNameFromColors, const QString& resultUnitFromColors, int m_activeTimeStepIndex, RimUnitSystem::UnitSystemType fractureTemplateUnit, double m_wellPathDepthAtFracture)
|
||||
{
|
||||
std::vector<RigFractureCell> stimPlanCells;
|
||||
std::pair<size_t, size_t> wellCenterStimPlanCellIJ = std::make_pair(0, 0);
|
||||
|
||||
bool wellCenterStimPlanCellFound = false;
|
||||
|
||||
std::vector<std::vector<double>> displayPropertyValuesAtTimeStep = this->getMirroredDataAtTimeIndex(resultNameFromColors, resultUnitFromColors, m_activeTimeStepIndex);
|
||||
|
||||
QString condUnit;
|
||||
if ( fractureTemplateUnit == RimUnitSystem::UNITS_METRIC ) condUnit = "md-m";
|
||||
if ( fractureTemplateUnit == RimUnitSystem::UNITS_FIELD ) condUnit = "md-ft";
|
||||
std::vector<std::vector<double>> conductivityValuesAtTimeStep = this->getMirroredDataAtTimeIndex("CONDUCTIVITY", condUnit, m_activeTimeStepIndex);
|
||||
|
||||
std::vector<double> depthCoordsAtNodes = this->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture);
|
||||
std::vector<double> xCoordsAtNodes = this->getNegAndPosXcoords();
|
||||
|
||||
std::vector<double> xCoords;
|
||||
for ( int i = 0; i < xCoordsAtNodes.size() - 1; i++ ) xCoords.push_back((xCoordsAtNodes[i] + xCoordsAtNodes[i + 1]) / 2);
|
||||
std::vector<double> depthCoords;
|
||||
for ( int i = 0; i < depthCoordsAtNodes.size() - 1; i++ ) depthCoords.push_back((depthCoordsAtNodes[i] + depthCoordsAtNodes[i + 1]) / 2);
|
||||
|
||||
for ( int i = 0; i < xCoords.size() - 1; i++ )
|
||||
{
|
||||
for ( int j = 0; j < depthCoords.size() - 1; j++ )
|
||||
{
|
||||
std::vector<cvf::Vec3d> cellPolygon;
|
||||
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i]), static_cast<float>(depthCoords[j]), 0.0));
|
||||
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i + 1]), static_cast<float>(depthCoords[j]), 0.0));
|
||||
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i + 1]), static_cast<float>(depthCoords[j + 1]), 0.0));
|
||||
cellPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[i]), static_cast<float>(depthCoords[j + 1]), 0.0));
|
||||
|
||||
RigFractureCell stimPlanCell(cellPolygon, i, j);
|
||||
if ( conductivityValuesAtTimeStep.size() > 0 ) //Assuming vector to be of correct length, or no values
|
||||
{
|
||||
stimPlanCell.setConductivityValue(conductivityValuesAtTimeStep[j + 1][i + 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
stimPlanCell.setConductivityValue(cvf::UNDEFINED_DOUBLE);
|
||||
}
|
||||
|
||||
if ( displayPropertyValuesAtTimeStep.size() > 0 )
|
||||
{
|
||||
stimPlanCell.setDisplayValue(displayPropertyValuesAtTimeStep[j + 1][i + 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
stimPlanCell.setDisplayValue(cvf::UNDEFINED_DOUBLE);
|
||||
}
|
||||
|
||||
if ( cellPolygon[0].x() < 0.0 && cellPolygon[1].x() > 0.0 )
|
||||
{
|
||||
if ( cellPolygon[1].y() > 0.0 && cellPolygon[2].y() < 0.0 )
|
||||
{
|
||||
wellCenterStimPlanCellIJ = std::make_pair(stimPlanCell.getI(), stimPlanCell.getJ());
|
||||
RiaLogging::debug(QString("Setting wellCenterStimPlanCell at cell %1, %2").
|
||||
arg(QString::number(stimPlanCell.getI()), QString::number(stimPlanCell.getJ())));
|
||||
|
||||
wellCenterStimPlanCellFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
stimPlanCells.push_back(stimPlanCell);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !wellCenterStimPlanCellFound )
|
||||
{
|
||||
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->getNegAndPosXcoords().size() - 2);
|
||||
m_fractureGrid->setJCellCount(this->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture).size() - 2);
|
||||
|
||||
return m_fractureGrid;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigStimPlanFractureDefinition::createFractureTriangleGeometry(double m_wellPathDepthAtFracture,
|
||||
RimUnitSystem::UnitSystem neededUnit,
|
||||
const QString& fractureUserName,
|
||||
std::vector<cvf::Vec3f>* vertices,
|
||||
std::vector<cvf::uint>* triangleIndices)
|
||||
{
|
||||
std::vector<double> xCoords = this->getNegAndPosXcoords();
|
||||
cvf::uint lenXcoords = static_cast<cvf::uint>(xCoords.size());
|
||||
|
||||
std::vector<double> adjustedDepths = this->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture);
|
||||
|
||||
if ( neededUnit == unitSet )
|
||||
{
|
||||
RiaLogging::debug(QString("No conversion necessary for %1").arg(fractureUserName));
|
||||
}
|
||||
|
||||
else if ( unitSet == RimUnitSystem::UNITS_METRIC && neededUnit == RimUnitSystem::UNITS_FIELD )
|
||||
{
|
||||
RiaLogging::info(QString("Converting StimPlan geometry from metric to field for fracture template %1").arg(fractureUserName));
|
||||
for ( double& value : adjustedDepths ) value = RimUnitSystem::meterToFeet(value);
|
||||
for ( double& value : xCoords ) value = RimUnitSystem::meterToFeet(value);
|
||||
}
|
||||
else if ( unitSet == RimUnitSystem::UNITS_FIELD && neededUnit == RimUnitSystem::UNITS_METRIC )
|
||||
{
|
||||
RiaLogging::info(QString("Converting StimPlan geometry from field to metric for fracture template %1").arg(fractureUserName));
|
||||
for ( double& value : adjustedDepths ) value = RimUnitSystem::feetToMeter(value);
|
||||
for ( double& value : xCoords ) value = RimUnitSystem::feetToMeter(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Should never get here...
|
||||
RiaLogging::error(QString("Error: Could not convert units for fracture template %1").arg(fractureUserName));
|
||||
return;
|
||||
}
|
||||
|
||||
for ( cvf::uint k = 0; k < adjustedDepths.size(); k++ )
|
||||
{
|
||||
for ( cvf::uint i = 0; i < lenXcoords; i++ )
|
||||
{
|
||||
cvf::Vec3f node = cvf::Vec3f(xCoords[i], adjustedDepths[k], 0);
|
||||
vertices->push_back(node);
|
||||
|
||||
if ( i < lenXcoords - 1 && k < adjustedDepths.size() - 1 )
|
||||
{
|
||||
if ( xCoords[i] < 1e-5 )
|
||||
{
|
||||
//Upper triangle
|
||||
triangleIndices->push_back(i + k*lenXcoords);
|
||||
triangleIndices->push_back((i + 1) + k*lenXcoords);
|
||||
triangleIndices->push_back((i + 1) + (k + 1)*lenXcoords);
|
||||
//Lower triangle
|
||||
triangleIndices->push_back(i + k*lenXcoords);
|
||||
triangleIndices->push_back((i + 1) + (k + 1)*lenXcoords);
|
||||
triangleIndices->push_back((i)+(k + 1)*lenXcoords);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//Upper triangle
|
||||
triangleIndices->push_back(i + k*lenXcoords);
|
||||
triangleIndices->push_back((i + 1) + k*lenXcoords);
|
||||
triangleIndices->push_back((i)+(k + 1)*lenXcoords);
|
||||
//Lower triangle
|
||||
triangleIndices->push_back((i + 1) + k*lenXcoords);
|
||||
triangleIndices->push_back((i + 1) + (k + 1)*lenXcoords);
|
||||
triangleIndices->push_back((i)+ (k + 1)*lenXcoords);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void sortPolygon(std::vector<cvf::Vec3f> &polygon)
|
||||
{
|
||||
if (polygon.size() == 0) return;
|
||||
|
||||
for (int i = 1; i < polygon.size() - 1; i++)
|
||||
{
|
||||
cvf::Vec3f lastNode = polygon[i - 1];
|
||||
cvf::Vec3f node = polygon[i];
|
||||
cvf::Vec3f nextNode = polygon[i + 1];
|
||||
|
||||
if (node.y() == nextNode.y())
|
||||
{
|
||||
if (lastNode.x() < node.x() && node.x() > nextNode.x())
|
||||
{
|
||||
polygon[i] = nextNode;
|
||||
polygon[i + 1] = node;
|
||||
}
|
||||
else if (lastNode.x() > node.x() && node.x() < nextNode.x())
|
||||
{
|
||||
polygon[i] = nextNode;
|
||||
polygon[i + 1] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::Vec3f> RigStimPlanFractureDefinition::createFractureBorderPolygon(const QString& resultName, const QString& resultUnit, int m_activeTimeStepIndex, double m_wellPathDepthAtFracture, RimUnitSystem::UnitSystem neededUnit, const QString& fractureUserName)
|
||||
{
|
||||
std::vector<cvf::Vec3f> polygon;
|
||||
|
||||
std::vector<std::vector<double>> dataAtTimeStep = this->getDataAtTimeIndex(resultName, resultUnit, m_activeTimeStepIndex);
|
||||
|
||||
std::vector<double> adjustedDepths = this->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture);
|
||||
|
||||
for ( int k = 0; k < dataAtTimeStep.size(); k++ )
|
||||
{
|
||||
for ( int i = 0; i < 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->gridXs[i]),
|
||||
static_cast<float>(adjustedDepths[k]), 0.0f));
|
||||
}
|
||||
else if ( (k < dataAtTimeStep.size() - 1) && ((dataAtTimeStep[k + 1])[(i)] > 1e-7) )//cell below different from 0
|
||||
{
|
||||
polygon.push_back(cvf::Vec3f(static_cast<float>(this->gridXs[i]),
|
||||
static_cast<float>(adjustedDepths[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->gridXs[i]),
|
||||
static_cast<float>(adjustedDepths[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]);
|
||||
|
||||
|
||||
if ( neededUnit == unitSet )
|
||||
{
|
||||
RiaLogging::debug(QString("No conversion necessary for %1").arg(fractureUserName));
|
||||
}
|
||||
|
||||
else if ( unitSet == RimUnitSystem::UNITS_METRIC && neededUnit == RimUnitSystem::UNITS_FIELD )
|
||||
{
|
||||
RiaLogging::info(QString("Converting StimPlan geometry from metric to field for fracture template %1").arg(fractureUserName));
|
||||
for ( cvf::Vec3f& node : polygon )
|
||||
{
|
||||
float x = RimUnitSystem::meterToFeet(node.x());
|
||||
float y = RimUnitSystem::meterToFeet(node.y());
|
||||
float z = RimUnitSystem::meterToFeet(node.z());
|
||||
node = cvf::Vec3f(x, y, z);
|
||||
}
|
||||
}
|
||||
else if ( unitSet == RimUnitSystem::UNITS_FIELD && neededUnit == RimUnitSystem::UNITS_METRIC )
|
||||
{
|
||||
RiaLogging::info(QString("Converting StimPlan geometry from field to metric for fracture template %1").arg(fractureUserName));
|
||||
for ( cvf::Vec3f& node : polygon )
|
||||
{
|
||||
float x = RimUnitSystem::feetToMeter(node.x());
|
||||
float y = RimUnitSystem::feetToMeter(node.y());
|
||||
float z = RimUnitSystem::feetToMeter(node.z());
|
||||
node = cvf::Vec3f(x, y, z);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Should never get here...
|
||||
RiaLogging::error(QString("Error: Could not convert units for fracture template %1").arg(fractureUserName));
|
||||
}
|
||||
|
||||
|
||||
return polygon;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -24,6 +24,9 @@
|
||||
|
||||
#include <vector>
|
||||
#include "RimUnitSystem.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
class RigFractureGrid;
|
||||
|
||||
class RigStimPlanResultFrames
|
||||
{
|
||||
@ -119,6 +122,25 @@ public:
|
||||
size_t timeStepIndex) const;
|
||||
|
||||
|
||||
cvf::ref<RigFractureGrid> createFractureGrid(const QString& resultNameFromColors,
|
||||
const QString& resultUnitFromColors,
|
||||
int m_activeTimeStepIndex,
|
||||
RimUnitSystem::UnitSystemType fractureTemplateUnit,
|
||||
double m_wellPathDepthAtFracture);
|
||||
|
||||
void createFractureTriangleGeometry(double m_wellPathDepthAtFracture,
|
||||
RimUnitSystem::UnitSystem neededUnit,
|
||||
const QString& fractureUserName,
|
||||
std::vector<cvf::Vec3f>* vertices,
|
||||
std::vector<cvf::uint>* triangleIndices);
|
||||
|
||||
std::vector<cvf::Vec3f> createFractureBorderPolygon(const QString& resultName,
|
||||
const QString& resultUnit,
|
||||
int m_activeTimeStepIndex,
|
||||
double m_wellPathDepthAtFracture,
|
||||
RimUnitSystem::UnitSystem neededUnit,
|
||||
const QString& fractureUserName);
|
||||
|
||||
std::vector<RigStimPlanResultFrames> stimPlanData;
|
||||
|
||||
bool timeStepExisist(double timeStepValue);
|
||||
|
Loading…
Reference in New Issue
Block a user