#1364 - pre-proto - Calculate H-A upscaled cond value for flow across layers

This commit is contained in:
astridkbjorke 2017-03-28 13:49:03 +02:00
parent 520ab45649
commit 926ced4dc5
5 changed files with 266 additions and 4 deletions

View File

@ -42,8 +42,8 @@ public:
std::vector<cvf::Vec3d> getPolygon() { return m_polygon; } std::vector<cvf::Vec3d> getPolygon() { return m_polygon; }
double getValue() { return m_value; } double getValue() { return m_value; }
size_t i() { return m_i; } size_t getI() { return m_i; }
size_t j() { return m_j; } size_t getJ() { return m_j; }
private: private:

View File

@ -804,6 +804,52 @@ std::vector<RimStimPlanCell*> RimStimPlanFractureTemplate::getStimPlanCells(cons
return stimPlanCells; return stimPlanCells;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RimStimPlanFractureTemplate::getStimPlanRowPolygon(size_t i) //Row with constant depth
{
std::vector<cvf::Vec3d> rowPolygon;
std::vector<double> depthCoordsAtNodes = adjustedDepthCoordsAroundWellPathPosition();
std::vector<double> xCoordsAtNodes = 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);
rowPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[0]), static_cast<float>(depthCoords[i]), 0.0));
rowPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords.back()), static_cast<float>(depthCoords[i]), 0.0));
rowPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords.back()), static_cast<float>(depthCoords[i+1]), 0.0));
rowPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[0]), static_cast<float>(depthCoords[i+1]), 0.0));
return rowPolygon;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RimStimPlanFractureTemplate::getStimPlanColPolygon(size_t j)
{
std::vector<cvf::Vec3d> colPolygon;
std::vector<double> depthCoordsAtNodes = adjustedDepthCoordsAroundWellPathPosition();
std::vector<double> xCoordsAtNodes = 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);
colPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[j]), static_cast<float>(depthCoords[0]), 0.0));
colPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[j+1]), static_cast<float>(depthCoords[0]), 0.0));
colPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[j+1]), static_cast<float>(depthCoords.back()), 0.0));
colPolygon.push_back(cvf::Vec3d(static_cast<float>(xCoords[j]), static_cast<float>(depthCoords.back()), 0.0));
return colPolygon;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -926,6 +972,22 @@ void RimStimPlanFractureTemplate::sortPolygon(std::vector<cvf::Vec3f> &polygon)
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimStimPlanFractureTemplate::stimPlanGridNumberOfColums()
{
return getNegAndPosXcoords().size();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimStimPlanFractureTemplate::stimPlanGridNumberOfRows()
{
return adjustedDepthCoordsAroundWellPathPosition().size();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -65,6 +65,10 @@ public:
std::vector<cvf::Vec3f> fracturePolygon(caf::AppEnum< RimDefines::UnitSystem > fractureUnit); std::vector<cvf::Vec3f> fracturePolygon(caf::AppEnum< RimDefines::UnitSystem > fractureUnit);
void sortPolygon(std::vector<cvf::Vec3f> &polygon); void sortPolygon(std::vector<cvf::Vec3f> &polygon);
size_t stimPlanGridNumberOfRows();
size_t stimPlanGridNumberOfColums();
std::vector<double> getNegAndPosXcoords(); std::vector<double> getNegAndPosXcoords();
std::vector<double> adjustedDepthCoordsAroundWellPathPosition(); std::vector<double> adjustedDepthCoordsAroundWellPathPosition();
std::vector<double> getStimPlanTimeValues(); std::vector<double> getStimPlanTimeValues();
@ -73,6 +77,9 @@ public:
void getStimPlanDataAsPolygonsAndValues(std::vector<std::vector<cvf::Vec3d> > &cellsAsPolygons, std::vector<double> &parameterValue, const QString& resultName, const QString& unitName, size_t timeStepIndex); void getStimPlanDataAsPolygonsAndValues(std::vector<std::vector<cvf::Vec3d> > &cellsAsPolygons, std::vector<double> &parameterValue, const QString& resultName, const QString& unitName, size_t timeStepIndex);
std::vector<RimStimPlanCell*> getStimPlanCells(const QString& resultName, const QString& unitName, size_t timeStepIndex); std::vector<RimStimPlanCell*> getStimPlanCells(const QString& resultName, const QString& unitName, size_t timeStepIndex);
std::vector<cvf::Vec3d> getStimPlanRowPolygon(size_t i);
std::vector<cvf::Vec3d> getStimPlanColPolygon(size_t j);
void loadDataAndUpdate(); void loadDataAndUpdate();
void setDefaultsBasedOnXMLfile(); void setDefaultsBasedOnXMLfile();

View File

@ -38,6 +38,7 @@
#include "RigMainGrid.h" #include "RigMainGrid.h"
#include "cvfMath.h" #include "cvfMath.h"
#include "RimDefines.h" #include "RimDefines.h"
#include "RimStimPlanCell.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@ -404,6 +405,134 @@ void RigFractureTransCalc::computeUpscaledPropertyFromStimPlanForEclipseCell(dou
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigFractureTransCalc::HAflowAcrossLayersUpscale(QString resultName, QString resultUnit, size_t timeStepIndex, RimDefines::UnitSystem unitSystem, size_t eclipseCellIndex)
{
//TODO: A lot of common code with function for calculating transmissibility...
RimStimPlanFractureTemplate* fracTemplateStimPlan;
if (dynamic_cast<RimStimPlanFractureTemplate*>(m_fracture->attachedFractureDefinition()))
{
fracTemplateStimPlan = dynamic_cast<RimStimPlanFractureTemplate*>(m_fracture->attachedFractureDefinition());
}
else return cvf::UNDEFINED_DOUBLE;
std::vector<RimStimPlanCell* > stimPlanCells = fracTemplateStimPlan->getStimPlanCells(resultName, resultUnit, timeStepIndex);
// RifReaderInterface::PorosityModelResultType porosityModel = RifReaderInterface::MATRIX_RESULTS;
// RimReservoirCellResultsStorage* gridCellResults = m_case->results(porosityModel);
cvf::Vec3d localX;
cvf::Vec3d localY;
cvf::Vec3d localZ;
std::vector<std::vector<cvf::Vec3d> > planeCellPolygons;
bool isPlanIntersected = planeCellIntersectionPolygons(eclipseCellIndex, planeCellPolygons, localX, localY, localZ);
if (!isPlanIntersected || planeCellPolygons.size() == 0) return cvf::UNDEFINED_DOUBLE;
//Transform planCell polygon(s) and averageZdirection to x/y coordinate system (where fracturePolygon/stimPlan mesh already is located)
cvf::Mat4f invertedTransMatrix = m_fracture->transformMatrix().getInverted();
for (std::vector<cvf::Vec3d> & planeCellPolygon : planeCellPolygons)
{
for (cvf::Vec3d& v : planeCellPolygon)
{
v.transformPoint(static_cast<cvf::Mat4d>(invertedTransMatrix));
}
}
//Vector for vertical - på tvers av lag... Gitt av orientering av stimPlan-grid...
cvf::Vec3d directionAcrossLayers;
cvf::Vec3d directionAlongLayers;
//TODO: Get these vectors properly...
directionAcrossLayers = cvf::Vec3d(0, -1, 0);
directionAlongLayers = cvf::Vec3d(1, 0, 0);
directionAcrossLayers.transformVector(static_cast<cvf::Mat4d>(invertedTransMatrix));
directionAlongLayers.transformVector(static_cast<cvf::Mat4d>(invertedTransMatrix));
std::vector<cvf::Vec3f> fracPolygon = m_fracture->attachedFractureDefinition()->fracturePolygon(unitSystem);
std::vector<std::vector<cvf::Vec3d> > polygonsDescribingFractureInCell;
std::vector<double> upscaledConductivities;
//Harmonic weighted mean
for (std::vector<cvf::Vec3d> planeCellPolygon : planeCellPolygons)
{
std::vector<double> DcolSum;
std::vector<double> lavgCol;
std::vector<double> CondHarmCol;
for (size_t j = 0; j < fracTemplateStimPlan->stimPlanGridNumberOfColums(); j++)
{
std::vector<double> conductivitiesInStimPlanCells;
std::vector<double> lengthsLiOfStimPlanCol;
std::vector<double> heightsDioFStimPlanCells;
std::vector<RimStimPlanCell*> stimPlanCellsCol = getColOfStimPlanCells(stimPlanCells, j);
for (RimStimPlanCell* stimPlanCell : stimPlanCellsCol)
{
if (stimPlanCell->getValue() > 1e-7)
{
std::vector<std::vector<cvf::Vec3d> >clippedStimPlanPolygons = RigCellGeometryTools::clipPolygons(stimPlanCell->getPolygon(), planeCellPolygon);
if (clippedStimPlanPolygons.size() > 0)
{
for (auto clippedStimPlanPolygon : clippedStimPlanPolygons)
{
conductivitiesInStimPlanCells.push_back(stimPlanCell->getValue());
lengthsLiOfStimPlanCol.push_back(RigCellGeometryTools::polygonAreaWeightedLength(directionAlongLayers, clippedStimPlanPolygon));
heightsDioFStimPlanCells.push_back(RigCellGeometryTools::polygonAreaWeightedLength(directionAcrossLayers, clippedStimPlanPolygon));
}
}
}
}
//Regne ut average
double sumDiDivCondLi = 0.0;
double sumDi = 0.0;
double sumLiDi = 0.0;
for (int i = 0; i < conductivitiesInStimPlanCells.size(); i++)
{
sumDiDivCondLi += heightsDioFStimPlanCells[i] / (conductivitiesInStimPlanCells[i] * lengthsLiOfStimPlanCol[i]);
sumDi += heightsDioFStimPlanCells[i];
sumLiDi += heightsDioFStimPlanCells[i] * lengthsLiOfStimPlanCol[i];
}
if (sumDiDivCondLi != 0)
{
DcolSum.push_back(sumDi);
double lAvgValue = sumLiDi / sumDi;
lavgCol.push_back(lAvgValue);
CondHarmCol.push_back(1 / (sumLiDi*sumDiDivCondLi));
}
}
//Do arithmetic upscaling based on harmonic upscaled values for coloums
double sumCondHLiDivDi = 0.0;
double sumLi = 0.0;
double sumDiLi = 0.0;
for (int i = 0; i < CondHarmCol.size(); i++)
{
sumLi += lavgCol[i];
sumDiLi += DcolSum[i] * lavgCol[i];
sumCondHLiDivDi += CondHarmCol[i] * lavgCol[i] / DcolSum[i];
}
double Davg = sumDiLi / sumLi;
double condHA = (Davg / sumLi) * sumCondHLiDivDi;
upscaledConductivities.push_back(condHA);
}
//TODO: Is this the right way of handling getting several values for each cell?
return arithmeticAverage(upscaledConductivities);
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -448,6 +577,25 @@ double RigFractureTransCalc::areaWeightedArithmeticAverage(std::vector<double> a
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigFractureTransCalc::arithmeticAverage(std::vector<double> values)
{
if (values.size() == 0) return cvf::UNDEFINED_DOUBLE;
double sumValue = 0.0;
size_t numberOfValues = 0;
for (double value : values)
{
sumValue += value;
numberOfValues++;
}
return sumValue / numberOfValues;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@ -600,6 +748,42 @@ void RigFractureTransCalc::computeFlowIntoTransverseWell()
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimStimPlanCell*> RigFractureTransCalc::getRowOfStimPlanCells(std::vector<RimStimPlanCell*> allStimPlanCells, size_t i)
{
std::vector<RimStimPlanCell*> stimPlanCellRow;
for (RimStimPlanCell* stimPlanCell : allStimPlanCells)
{
if (stimPlanCell->getI() == i)
{
stimPlanCellRow.push_back(stimPlanCell);
}
}
return stimPlanCellRow;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimStimPlanCell*> RigFractureTransCalc::getColOfStimPlanCells(std::vector<RimStimPlanCell*> allStimPlanCells, size_t j)
{
std::vector<RimStimPlanCell*> stimPlanCellCol;
for (RimStimPlanCell* stimPlanCell : allStimPlanCells)
{
if (stimPlanCell->getJ() == j)
{
stimPlanCellCol.push_back(stimPlanCell);
}
}
return stimPlanCellCol;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -35,7 +35,7 @@
class RimFracture; class RimFracture;
class RimEclipseCase; class RimEclipseCase;
class RimStimPlanCell;
//================================================================================================== //==================================================================================================
/// ///
@ -52,13 +52,22 @@ public:
void computeUpscaledPropertyFromStimPlan(QString resultName, QString resultUnit, size_t timeStepIndex); void computeUpscaledPropertyFromStimPlan(QString resultName, QString resultUnit, size_t timeStepIndex);
void computeUpscaledPropertyFromStimPlanForEclipseCell(double &upscaledAritmStimPlanValue, double &upscaledHarmStimPlanValue, QString resultName, QString resultUnit, size_t timeStepIndex, caf::AppEnum< RimDefines::UnitSystem > unitSystem, size_t cellIndex); void computeUpscaledPropertyFromStimPlanForEclipseCell(double &upscaledAritmStimPlanValue, double &upscaledHarmStimPlanValue, QString resultName, QString resultUnit, size_t timeStepIndex, caf::AppEnum< RimDefines::UnitSystem > unitSystem, size_t cellIndex);
double HAflowAcrossLayersUpscale(QString resultName, QString resultUnit, size_t timeStepIndex, RimDefines::UnitSystem unitSystem, size_t eclipseCellIndex);
static double areaWeightedHarmonicAverage(std::vector<double> areaOfFractureParts, std::vector<double> valuesForFractureParts); static double areaWeightedHarmonicAverage(std::vector<double> areaOfFractureParts, std::vector<double> valuesForFractureParts);
static double areaWeightedArithmeticAverage(std::vector<double> areaOfFractureParts, std::vector<double> valuesForFractureParts); static double areaWeightedArithmeticAverage(std::vector<double> areaOfFractureParts, std::vector<double> valuesForFractureParts);
static double arithmeticAverage(std::vector<double> values);
void computeFlowInFracture(); void computeFlowInFracture();
void computeFlowIntoTransverseWell(); void computeFlowIntoTransverseWell();
static std::vector<RimStimPlanCell*> getRowOfStimPlanCells(std::vector<RimStimPlanCell*> allStimPlanCells, size_t i);
static std::vector<RimStimPlanCell*> getColOfStimPlanCells(std::vector<RimStimPlanCell*> allStimPlanCells, size_t j);
private: private:
RimEclipseCase* m_case; RimEclipseCase* m_case;
RimFracture* m_fracture; RimFracture* m_fracture;