#1487 Remove dependency on RiaApplication and active view in RigEclipseToStimPlanCellTransCalc. Make m_case const. Some cleaning

This commit is contained in:
Jacob Støren
2017-05-16 16:40:37 +02:00
parent cac9a9ed03
commit 84a1940d6a
2 changed files with 51 additions and 59 deletions

View File

@@ -26,32 +26,26 @@
#include "RigMainGrid.h" #include "RigMainGrid.h"
#include "RimEclipseCase.h" #include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimReservoirCellResultsStorage.h" #include "RimReservoirCellResultsStorage.h"
#include "RiaApplication.h"
#include "cvfGeometryTools.h" #include "cvfGeometryTools.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigEclipseToStimPlanCellTransmissibilityCalculator::RigEclipseToStimPlanCellTransmissibilityCalculator(RimEclipseCase* caseToApply, RigEclipseToStimPlanCellTransmissibilityCalculator::RigEclipseToStimPlanCellTransmissibilityCalculator(const RimEclipseCase* caseToApply,
cvf::Mat4f fractureTransform, cvf::Mat4f fractureTransform,
double skinFactor, double skinFactor,
double cDarcy, double cDarcy,
const RigStimPlanFracTemplateCell& stimPlanCell) const RigStimPlanFracTemplateCell& stimPlanCell)
: m_case(caseToApply),
: m_stimPlanCell(stimPlanCell) m_fractureTransform(fractureTransform),
m_fractureSkinFactor(skinFactor),
m_cDarcy(cDarcy),
m_stimPlanCell(stimPlanCell)
{ {
m_case = caseToApply;
m_fractureSkinFactor = skinFactor;
m_cDarcy = cDarcy;
m_fractureTransform = fractureTransform;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -83,11 +77,10 @@ const std::vector<double>& RigEclipseToStimPlanCellTransmissibilityCalculator::c
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsMatrixTransmissibility() void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsMatrixTransmissibility()
{ {
// Not calculating flow into fracture if stimPlan cell cond value is 0 (assumed to be outside the fracture):
//Not calculating flow into fracture if stimPlan cell cond value is 0 (assumed to be outside the fracture):
if (m_stimPlanCell.getConductivtyValue() < 1e-7) return; if (m_stimPlanCell.getConductivtyValue() < 1e-7) return;
RigEclipseCaseData* eclipseCaseData = m_case->eclipseCaseData(); const RigEclipseCaseData* eclipseCaseData = m_case->eclipseCaseData();
RifReaderInterface::PorosityModelResultType porosityModel = RifReaderInterface::MATRIX_RESULTS; RifReaderInterface::PorosityModelResultType porosityModel = RifReaderInterface::MATRIX_RESULTS;
RimReservoirCellResultsStorage* gridCellResults = m_case->results(porosityModel); RimReservoirCellResultsStorage* gridCellResults = m_case->results(porosityModel);
@@ -109,7 +102,7 @@ void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsM
scalarSetIndex = gridCellResults->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "NTG"); scalarSetIndex = gridCellResults->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "NTG");
cvf::ref<RigResultAccessor> dataAccessObjectNTG = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, porosityModel, 0, "NTG"); //assuming 0 time step and main grid (so grid index =0) cvf::ref<RigResultAccessor> dataAccessObjectNTG = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, porosityModel, 0, "NTG"); //assuming 0 time step and main grid (so grid index =0)
RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(porosityModel); const RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(porosityModel);
std::vector<cvf::Vec3d> stimPlanPolygonTransformed; std::vector<cvf::Vec3d> stimPlanPolygonTransformed;
for (cvf::Vec3d v : m_stimPlanCell.getPolygon()) for (cvf::Vec3d v : m_stimPlanCell.getPolygon())
@@ -119,7 +112,6 @@ void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsM
stimPlanPolygonTransformed.push_back(static_cast<cvf::Vec3d>(stimPlanPolygonNode)); stimPlanPolygonTransformed.push_back(static_cast<cvf::Vec3d>(stimPlanPolygonNode));
} }
std::vector<size_t> fracCells = getPotentiallyFracturedCellsForPolygon(stimPlanPolygonTransformed); std::vector<size_t> fracCells = getPotentiallyFracturedCellsForPolygon(stimPlanPolygonTransformed);
for (size_t fracCell : fracCells) for (size_t fracCell : fracCells)
{ {
@@ -211,8 +203,6 @@ void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsM
double fractureAreaWeightedlength = totalAreaXLength / fractureArea; double fractureAreaWeightedlength = totalAreaXLength / fractureArea;
double transmissibility_X = calculateMatrixTransmissibility(permY, NTG, Ay, dx, m_fractureSkinFactor, fractureAreaWeightedlength); double transmissibility_X = calculateMatrixTransmissibility(permY, NTG, Ay, dx, m_fractureSkinFactor, fractureAreaWeightedlength);
double transmissibility_Y = calculateMatrixTransmissibility(permX, NTG, Ax, dy, m_fractureSkinFactor, fractureAreaWeightedlength); double transmissibility_Y = calculateMatrixTransmissibility(permX, NTG, Ax, dy, m_fractureSkinFactor, fractureAreaWeightedlength);
double transmissibility_Z = calculateMatrixTransmissibility(permZ, 1.0, Az, dz, m_fractureSkinFactor, fractureAreaWeightedlength); double transmissibility_Z = calculateMatrixTransmissibility(permZ, 1.0, Az, dz, m_fractureSkinFactor, fractureAreaWeightedlength);
@@ -224,9 +214,7 @@ void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsM
m_globalIndeciesToContributingEclipseCells.push_back(fracCell); m_globalIndeciesToContributingEclipseCells.push_back(fracCell);
m_contributingEclipseCellTransmissibilities.push_back(transmissibility); m_contributingEclipseCellTransmissibilities.push_back(transmissibility);
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -234,36 +222,28 @@ void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsM
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<size_t> RigEclipseToStimPlanCellTransmissibilityCalculator::getPotentiallyFracturedCellsForPolygon(std::vector<cvf::Vec3d> polygon) std::vector<size_t> RigEclipseToStimPlanCellTransmissibilityCalculator::getPotentiallyFracturedCellsForPolygon(std::vector<cvf::Vec3d> polygon)
{ {
std::vector<size_t> cellindecies; std::vector<size_t> cellIndices;
RiaApplication* app = RiaApplication::instance(); const RigMainGrid* mainGrid = m_case->eclipseCaseData()->mainGrid();
RimView* activeView = RiaApplication::instance()->activeReservoirView(); if (!mainGrid) return cellIndices;
if (!activeView) return cellindecies;
RimEclipseView* activeRiv = dynamic_cast<RimEclipseView*>(activeView);
if (!activeRiv) return cellindecies;
const RigMainGrid* mainGrid = activeRiv->mainGrid();
if (!mainGrid) return cellindecies;
cvf::BoundingBox polygonBBox; cvf::BoundingBox polygonBBox;
for (cvf::Vec3d nodeCoord : polygon) polygonBBox.add(nodeCoord); for (cvf::Vec3d nodeCoord : polygon) polygonBBox.add(nodeCoord);
mainGrid->findIntersectingCells(polygonBBox, &cellindecies); mainGrid->findIntersectingCells(polygonBBox, &cellIndices);
return cellindecies; return cellIndices;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RigEclipseToStimPlanCellTransmissibilityCalculator::planeCellIntersectionPolygons(size_t cellindex, std::vector<std::vector<cvf::Vec3d> > & polygons, bool RigEclipseToStimPlanCellTransmissibilityCalculator::planeCellIntersectionPolygons(size_t cellindex,
cvf::Vec3d & localX, cvf::Vec3d & localY, cvf::Vec3d & localZ) std::vector<std::vector<cvf::Vec3d> > & polygons,
cvf::Vec3d & localX,
cvf::Vec3d & localY,
cvf::Vec3d & localZ)
{ {
cvf::Plane fracturePlane; cvf::Plane fracturePlane;
bool isCellIntersected = false; bool isCellIntersected = false;
@@ -305,7 +285,12 @@ bool RigEclipseToStimPlanCellTransmissibilityCalculator::planeCellIntersectionPo
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
double RigEclipseToStimPlanCellTransmissibilityCalculator::calculateMatrixTransmissibility(double perm, double NTG, double A, double cellSizeLength, double skinfactor, double fractureAreaWeightedlength) double RigEclipseToStimPlanCellTransmissibilityCalculator::calculateMatrixTransmissibility(double perm,
double NTG,
double A,
double cellSizeLength,
double skinfactor,
double fractureAreaWeightedlength)
{ {
double transmissibility; double transmissibility;

View File

@@ -33,24 +33,31 @@ class RigStimPlanFracTemplateCell;
class RigEclipseToStimPlanCellTransmissibilityCalculator class RigEclipseToStimPlanCellTransmissibilityCalculator
{ {
public: public:
explicit RigEclipseToStimPlanCellTransmissibilityCalculator(RimEclipseCase* caseToApply, explicit RigEclipseToStimPlanCellTransmissibilityCalculator(const RimEclipseCase* caseToApply,
cvf::Mat4f fractureTransform, cvf::Mat4f fractureTransform,
double skinFactor, double skinFactor,
double cDarcy, double cDarcy,
const RigStimPlanFracTemplateCell& stimPlanCell); const RigStimPlanFracTemplateCell& stimPlanCell);
const std::vector<size_t>& globalIndeciesToContributingEclipseCells(); const std::vector<size_t>& globalIndeciesToContributingEclipseCells();
const std::vector<double>& contributingEclipseCellTransmissibilities(); const std::vector<double>& contributingEclipseCellTransmissibilities();
private: private:
void calculateStimPlanCellsMatrixTransmissibility(); void calculateStimPlanCellsMatrixTransmissibility();
static std::vector<size_t> getPotentiallyFracturedCellsForPolygon(std::vector<cvf::Vec3d> polygon); std::vector<size_t> getPotentiallyFracturedCellsForPolygon(std::vector<cvf::Vec3d> polygon);
bool planeCellIntersectionPolygons(size_t cellindex, std::vector<std::vector<cvf::Vec3d> > & polygons, bool planeCellIntersectionPolygons(size_t cellindex,
cvf::Vec3d & localX, cvf::Vec3d & localY, cvf::Vec3d & localZ); std::vector<std::vector<cvf::Vec3d> > & polygons,
double calculateMatrixTransmissibility(double permX, double NTG, double Ay, double dx, double skinfactor, double fractureAreaWeightedlength); cvf::Vec3d & localX,
cvf::Vec3d & localY,
cvf::Vec3d & localZ);
double calculateMatrixTransmissibility(double permX,
double NTG,
double Ay,
double dx,
double skinfactor,
double fractureAreaWeightedlength);
const RimEclipseCase* m_case;
RimEclipseCase* m_case;
double m_cDarcy; double m_cDarcy;
double m_fractureSkinFactor; double m_fractureSkinFactor;
cvf::Mat4f m_fractureTransform; cvf::Mat4f m_fractureTransform;