2017-01-02 07:13:34 -06:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
# include "RimFracture.h"
2017-01-19 03:43:23 -06:00
# include "RiaApplication.h"
2017-06-14 00:25:34 -05:00
# include "RiaEclipseUnitTools.h"
2017-03-06 08:14:11 -06:00
# include "RiaLogging.h"
2017-01-19 03:43:23 -06:00
2017-01-30 03:45:18 -06:00
# include "RifReaderInterface.h"
2017-01-31 08:58:13 -06:00
# include "RigActiveCellInfo.h"
2017-01-30 03:45:18 -06:00
# include "RigCaseCellResultsData.h"
2017-01-19 03:43:23 -06:00
# include "RigCell.h"
2017-01-23 08:22:51 -06:00
# include "RigCellGeometryTools.h"
2017-01-30 03:45:18 -06:00
# include "RigEclipseCaseData.h"
2017-12-15 06:09:47 -06:00
# include "RigHexIntersectionTools.h"
2017-01-19 03:43:23 -06:00
# include "RigMainGrid.h"
2017-01-30 03:45:18 -06:00
# include "RigResultAccessor.h"
# include "RigResultAccessorFactory.h"
2017-01-04 01:10:02 -06:00
# include "RigTesselatorTools.h"
2017-01-10 06:37:50 -06:00
2017-01-30 03:45:18 -06:00
# include "RimEclipseCase.h"
# include "RimEclipseCellColors.h"
2017-01-19 03:43:23 -06:00
# include "RimEclipseView.h"
2017-01-12 06:29:18 -06:00
# include "RimEllipseFractureTemplate.h"
2017-12-15 06:09:47 -06:00
# include "RimFractureContainment.h"
2017-06-15 03:49:27 -05:00
# include "RimFractureTemplate.h"
2017-02-07 04:08:56 -06:00
# include "RimFractureTemplateCollection.h"
2017-01-19 03:43:23 -06:00
# include "RimOilField.h"
# include "RimProject.h"
2017-01-31 08:58:13 -06:00
# include "RimReservoirCellResultsStorage.h"
2017-02-15 05:16:01 -06:00
# include "RimStimPlanFractureTemplate.h"
2017-01-10 06:37:50 -06:00
# include "RimView.h"
2017-01-19 03:43:23 -06:00
# include "RivWellFracturePartMgr.h"
# include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h"
2017-12-15 06:09:47 -06:00
2017-02-15 04:29:44 -06:00
# include "cafPdmUiDoubleSliderEditor.h"
# include "cafPdmUiTreeOrdering.h"
2017-01-02 07:13:34 -06:00
2017-12-15 06:09:47 -06:00
# include "clipper/clipper.hpp"
2017-01-19 03:43:23 -06:00
# include "cvfBoundingBox.h"
# include "cvfGeometryTools.h"
2017-01-11 07:32:15 -06:00
# include "cvfMath.h"
2017-01-10 06:37:50 -06:00
# include "cvfMatrix4.h"
2017-01-13 08:49:21 -06:00
# include "cvfPlane.h"
2017-01-19 03:43:23 -06:00
2017-02-15 05:16:01 -06:00
# include <QString>
2017-12-15 06:09:47 -06:00
# include <math.h>
2017-01-02 07:13:34 -06:00
2017-01-04 01:10:02 -06:00
CAF_PDM_XML_ABSTRACT_SOURCE_INIT ( RimFracture , " Fracture " ) ;
2017-01-02 07:13:34 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFracture : : RimFracture ( void )
{
CAF_PDM_InitObject ( " Fracture " , " " , " " , " " ) ;
2017-01-19 03:43:23 -06:00
CAF_PDM_InitFieldNoDefault ( & m_fractureTemplate , " FractureDef " , " Fracture Template " , " " , " " , " " ) ;
2017-12-15 06:09:47 -06:00
CAF_PDM_InitFieldNoDefault ( & m_anchorPosition , " AnchorPosition " , " Anchor Position " , " " , " " , " " ) ;
2017-01-19 03:43:23 -06:00
m_anchorPosition . uiCapability ( ) - > setUiHidden ( true ) ;
2017-01-19 06:35:07 -06:00
CAF_PDM_InitFieldNoDefault ( & m_uiAnchorPosition , " ui_positionAtWellpath " , " Fracture Position " , " " , " " , " " ) ;
2017-01-19 03:43:23 -06:00
m_uiAnchorPosition . registerGetMethod ( this , & RimFracture : : fracturePositionForUi ) ;
m_uiAnchorPosition . uiCapability ( ) - > setUiReadOnly ( true ) ;
2017-12-15 06:09:47 -06:00
m_uiAnchorPosition . xmlCapability ( ) - > disableIO ( ) ;
2017-06-16 07:13:42 -05:00
2017-01-10 03:53:54 -06:00
CAF_PDM_InitField ( & azimuth , " Azimuth " , 0.0 , " Azimuth " , " " , " " , " " ) ;
2017-02-15 05:16:01 -06:00
azimuth . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiDoubleSliderEditor : : uiEditorTypeName ( ) ) ;
2017-06-16 07:13:42 -05:00
2017-06-08 04:00:35 -05:00
CAF_PDM_InitField ( & perforationLength , " PerforationLength " , 1.0 , " Perforation Length " , " " , " " , " " ) ;
2017-12-15 06:09:47 -06:00
CAF_PDM_InitField ( & perforationEfficiency , " PerforationEfficiency " , 1.0 , " Perforation Efficiency " , " " , " " , " " ) ;
2017-04-18 08:23:26 -05:00
perforationEfficiency . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiDoubleSliderEditor : : uiEditorTypeName ( ) ) ;
2017-06-16 07:13:42 -05:00
2017-12-15 06:09:47 -06:00
CAF_PDM_InitField ( & wellDiameter , " WellDiameter " , 0.216 , " Well Diameter at Fracture " , " " , " " , " " ) ;
2017-03-06 06:32:42 -06:00
CAF_PDM_InitField ( & dip , " Dip " , 0.0 , " Dip " , " " , " " , " " ) ;
2017-03-29 03:12:01 -05:00
CAF_PDM_InitField ( & tilt , " Tilt " , 0.0 , " Tilt " , " " , " " , " " ) ;
2017-12-15 06:09:47 -06:00
CAF_PDM_InitField ( & showPolygonFractureOutline , " ShowPolygonFractureOutline " , false , " Show Polygon Outline " , " " , " " , " " ) ;
2017-06-30 05:54:51 -05:00
showPolygonFractureOutline . uiCapability ( ) - > setUiHidden ( true ) ;
2017-12-15 06:09:47 -06:00
CAF_PDM_InitField ( & m_fractureUnit , " FractureUnit " , caf : : AppEnum < RiaEclipseUnitTools : : UnitSystem > ( RiaEclipseUnitTools : : UNITS_METRIC ) , " Fracture Unit System " , " " , " " , " " ) ;
2017-06-20 07:46:58 -05:00
m_fractureUnit . uiCapability ( ) - > setUiReadOnly ( true ) ;
2017-01-23 01:54:27 -06:00
2017-12-15 06:09:47 -06:00
CAF_PDM_InitField ( & stimPlanTimeIndexToPlot , " TimeIndexToPlot " , 0 , " StimPlan Time Step " , " " , " " , " " ) ;
2017-01-10 03:53:54 -06:00
2017-06-29 03:34:20 -05:00
CAF_PDM_InitFieldNoDefault ( & m_uiWellPathAzimuth , " WellPathAzimuth " , " Well Path Azimuth " , " " , " " , " " ) ;
2017-06-29 04:28:30 -05:00
m_uiWellPathAzimuth . registerGetMethod ( this , & RimFracture : : wellAzimuthAtFracturePositionText ) ;
2017-06-29 03:34:20 -05:00
m_uiWellPathAzimuth . uiCapability ( ) - > setUiReadOnly ( true ) ;
2017-12-15 06:09:47 -06:00
m_uiWellPathAzimuth . xmlCapability ( ) - > disableIO ( ) ;
2017-08-30 01:34:42 -05:00
CAF_PDM_InitFieldNoDefault ( & m_uiWellFractureAzimuthDiff , " WellFractureAzimuthDiff " , " Azimuth Difference Between \n Fracture and Well " , " " , " " , " " ) ;
2017-06-29 04:28:30 -05:00
m_uiWellFractureAzimuthDiff . registerGetMethod ( this , & RimFracture : : wellFractureAzimuthDiffText ) ;
2017-06-29 03:34:20 -05:00
m_uiWellFractureAzimuthDiff . uiCapability ( ) - > setUiReadOnly ( true ) ;
2017-12-15 06:09:47 -06:00
m_uiWellFractureAzimuthDiff . xmlCapability ( ) - > disableIO ( ) ;
2017-06-27 07:11:55 -05:00
CAF_PDM_InitField ( & m_wellFractureAzimuthAngleWarning , " WellFractureAzimithAngleWarning " , QString ( " Difference is below 10 degrees. Consider longitudinal fracture " ) , " " , " " , " " , " " ) ;
2017-06-29 03:34:20 -05:00
m_wellFractureAzimuthAngleWarning . uiCapability ( ) - > setUiReadOnly ( true ) ;
2017-12-15 06:09:47 -06:00
m_wellFractureAzimuthAngleWarning . xmlCapability ( ) - > disableIO ( ) ;
2017-06-26 08:09:33 -05:00
2017-06-09 10:21:59 -05:00
m_fracturePartMgr = new RivWellFracturePartMgr ( this ) ;
2017-01-02 07:13:34 -06:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFracture : : ~ RimFracture ( )
{
}
2017-01-04 01:10:02 -06:00
2017-01-12 05:19:52 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-05-16 10:52:57 -05:00
std : : vector < size_t > RimFracture : : getPotentiallyFracturedCells ( const RigMainGrid * mainGrid )
2017-01-12 05:19:52 -06:00
{
std : : vector < size_t > cellindecies ;
if ( ! mainGrid ) return cellindecies ;
2017-06-12 05:45:09 -05:00
cvf : : BoundingBox fractureBBox = this - > boundingBoxInDomainCoords ( ) ;
2017-01-12 05:19:52 -06:00
2017-06-12 05:45:09 -05:00
mainGrid - > findIntersectingCells ( fractureBBox , & cellindecies ) ;
2017-01-12 05:19:52 -06:00
return cellindecies ;
}
2017-01-10 06:37:50 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFracture : : fieldChangedByUi ( const caf : : PdmFieldHandle * changedField , const QVariant & oldValue , const QVariant & newValue )
{
2017-01-23 02:46:33 -06:00
if ( changedField = = & m_fractureTemplate )
{
2017-06-15 03:49:27 -05:00
setFractureTemplate ( m_fractureTemplate ) ;
2017-01-23 02:46:33 -06:00
}
2017-01-19 03:43:23 -06:00
if ( changedField = = & azimuth | |
2017-02-15 08:49:53 -06:00
changedField = = & m_fractureTemplate | |
2017-02-22 06:29:20 -06:00
changedField = = & stimPlanTimeIndexToPlot | |
2017-02-28 07:28:14 -06:00
changedField = = this - > objectToggleField ( ) | |
2017-03-02 03:08:45 -06:00
changedField = = & showPolygonFractureOutline | |
2017-03-29 03:12:01 -05:00
changedField = = & dip | |
changedField = = & tilt )
2017-01-10 06:37:50 -06:00
{
2017-01-23 01:54:27 -06:00
2017-06-12 05:45:09 -05:00
clearDisplayGeometryCache ( ) ;
2017-01-10 06:37:50 -06:00
RimView * rimView = nullptr ;
this - > firstAncestorOrThisOfType ( rimView ) ;
if ( rimView )
{
rimView - > createDisplayModelAndRedraw ( ) ;
}
2017-01-19 03:43:23 -06:00
else
{
// Can be triggered from well path, find active view
2017-06-16 02:44:39 -05:00
RimProject * proj ;
this - > firstAncestorOrThisOfTypeAsserted ( proj ) ;
proj - > reloadCompletionTypeResultsInAllViews ( ) ;
2017-01-19 03:43:23 -06:00
}
2017-01-10 06:37:50 -06:00
}
2017-01-23 01:54:27 -06:00
2017-01-10 06:37:50 -06:00
}
2017-01-19 06:35:07 -06:00
//--------------------------------------------------------------------------------------------------
2017-02-06 04:44:24 -06:00
///
//--------------------------------------------------------------------------------------------------
cvf : : Vec3d RimFracture : : fracturePosition ( ) const
{
return m_anchorPosition ;
}
2017-06-29 03:34:20 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimFracture : : wellFractureAzimuthDiff ( ) const
{
double wellDifference = abs ( wellAzimuthAtFracturePosition ( ) - azimuth ) ;
return wellDifference ;
}
2017-06-29 04:28:30 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimFracture : : wellFractureAzimuthDiffText ( ) const
{
double wellDifference = wellFractureAzimuthDiff ( ) ;
return QString : : number ( wellDifference , ' f ' , 2 ) ;
}
QString RimFracture : : wellAzimuthAtFracturePositionText ( ) const
{
double wellAzimuth = wellAzimuthAtFracturePosition ( ) ;
return QString : : number ( wellAzimuth , ' f ' , 2 ) ;
}
2017-01-04 01:10:02 -06:00
//--------------------------------------------------------------------------------------------------
2017-06-09 06:05:59 -05:00
///
//--------------------------------------------------------------------------------------------------
cvf : : BoundingBox RimFracture : : boundingBoxInDomainCoords ( )
{
2017-06-12 05:45:09 -05:00
std : : vector < cvf : : Vec3f > nodeCoordVec ;
std : : vector < cvf : : uint > triangleIndices ;
2017-06-09 06:05:59 -05:00
2017-06-12 05:45:09 -05:00
this - > triangleGeometry ( & triangleIndices , & nodeCoordVec ) ;
2017-06-09 06:05:59 -05:00
2017-06-12 05:45:09 -05:00
cvf : : BoundingBox fractureBBox ;
for ( cvf : : Vec3f nodeCoord : nodeCoordVec ) fractureBBox . add ( nodeCoord ) ;
return fractureBBox ;
2017-06-09 06:05:59 -05:00
}
2017-01-12 03:52:47 -06:00
2017-06-08 02:15:50 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-06-20 07:46:58 -05:00
double RimFracture : : wellRadius ( RiaEclipseUnitTools : : UnitSystem unitSystem ) const
2017-06-08 02:15:50 -05:00
{
2017-06-20 07:46:58 -05:00
if ( m_fractureUnit = = RiaEclipseUnitTools : : UNITS_METRIC )
2017-06-08 02:15:50 -05:00
{
2017-06-20 07:46:58 -05:00
if ( unitSystem = = RiaEclipseUnitTools : : UNITS_FIELD )
{
return RiaEclipseUnitTools : : meterToFeet ( wellDiameter / 2 ) ;
}
else
{
return wellDiameter / 2 ;
}
2017-06-08 02:15:50 -05:00
}
2017-06-20 07:46:58 -05:00
else if ( m_fractureUnit = = RiaEclipseUnitTools : : UNITS_FIELD )
2017-06-08 02:15:50 -05:00
{
2017-06-20 07:46:58 -05:00
if ( unitSystem = = RiaEclipseUnitTools : : UNITS_METRIC )
{
return RiaEclipseUnitTools : : inchToMeter ( wellDiameter / 2 ) ;
}
else
{
return RiaEclipseUnitTools : : inchToFeet ( wellDiameter / 2 ) ;
}
2017-06-08 02:15:50 -05:00
}
return cvf : : UNDEFINED_DOUBLE ;
}
2017-01-19 03:43:23 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-05-22 11:11:03 -05:00
cvf : : Vec3d RimFracture : : anchorPosition ( ) const
2017-01-19 03:43:23 -06:00
{
return m_anchorPosition ( ) ;
}
2017-01-12 03:52:47 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-06-23 03:16:39 -05:00
cvf : : Mat4d RimFracture : : transformMatrix ( ) const
2017-01-12 03:52:47 -06:00
{
2017-01-19 03:43:23 -06:00
cvf : : Vec3d center = anchorPosition ( ) ;
2017-01-12 03:52:47 -06:00
2017-03-06 06:32:42 -06:00
// Dip (in XY plane)
2017-06-23 03:16:39 -05:00
cvf : : Mat4d dipRotation = cvf : : Mat4d : : fromRotation ( cvf : : Vec3d : : Z_AXIS , cvf : : Math : : toRadians ( dip ( ) ) ) ;
2017-03-06 06:32:42 -06:00
2017-03-29 03:12:01 -05:00
// Dip (out of XY plane)
2017-06-23 03:16:39 -05:00
cvf : : Mat4d tiltRotation = cvf : : Mat4d : : fromRotation ( cvf : : Vec3d : : X_AXIS , cvf : : Math : : toRadians ( tilt ( ) ) ) ;
2017-03-29 03:12:01 -05:00
2017-01-10 06:37:50 -06:00
// Ellipsis geometry is produced in XY-plane, rotate 90 deg around X to get zero azimuth along Y
2017-06-23 03:16:39 -05:00
cvf : : Mat4d rotationFromTesselator = cvf : : Mat4d : : fromRotation ( cvf : : Vec3d : : X_AXIS , cvf : : Math : : toRadians ( 90.0f ) ) ;
2017-03-06 06:32:42 -06:00
2017-01-10 06:37:50 -06:00
// Azimuth rotation
2017-06-23 03:16:39 -05:00
cvf : : Mat4d azimuthRotation = cvf : : Mat4d : : fromRotation ( cvf : : Vec3d : : Z_AXIS , cvf : : Math : : toRadians ( - azimuth ( ) - 90 ) ) ;
2017-01-10 06:37:50 -06:00
2017-06-23 03:16:39 -05:00
cvf : : Mat4d m = azimuthRotation * rotationFromTesselator * dipRotation * tiltRotation ;
m . setTranslation ( center ) ;
2017-01-10 06:37:50 -06:00
2017-01-12 03:52:47 -06:00
return m ;
}
2017-01-04 01:10:02 -06:00
2017-01-06 06:13:25 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-06-12 05:45:09 -05:00
void RimFracture : : clearDisplayGeometryCache ( )
2017-01-06 06:13:25 -06:00
{
2017-06-09 10:21:59 -05:00
m_fracturePartMgr - > clearGeometryCache ( ) ;
2017-01-06 06:13:25 -06:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-06-12 05:45:09 -05:00
void RimFracture : : triangleGeometry ( std : : vector < cvf : : uint > * triangleIndices , std : : vector < cvf : : Vec3f > * nodeCoords )
2017-01-06 06:13:25 -06:00
{
2017-06-12 05:45:09 -05:00
RimFractureTemplate * fractureDef = fractureTemplate ( ) ;
if ( fractureDef )
{
fractureDef - > fractureTriangleGeometry ( nodeCoords , triangleIndices , fractureUnit ( ) ) ;
}
2017-06-23 03:16:39 -05:00
cvf : : Mat4d m = transformMatrix ( ) ;
2017-06-12 05:45:09 -05:00
for ( cvf : : Vec3f & v : * nodeCoords )
{
2017-06-23 03:16:39 -05:00
cvf : : Vec3d vd ( v ) ;
vd . transformPoint ( m ) ;
v = cvf : : Vec3f ( vd ) ;
2017-06-12 05:45:09 -05:00
}
2017-01-04 01:10:02 -06:00
}
2017-06-12 05:45:09 -05:00
2017-01-19 03:43:23 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf : : Vec3d RimFracture : : fracturePositionForUi ( ) const
{
cvf : : Vec3d v = m_anchorPosition ;
v . z ( ) = - v . z ( ) ;
return v ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList < caf : : PdmOptionItemInfo > RimFracture : : calculateValueOptions ( const caf : : PdmFieldHandle * fieldNeedingOptions , bool * useOptionsOnly )
{
QList < caf : : PdmOptionItemInfo > options ;
RimProject * proj = RiaApplication : : instance ( ) - > project ( ) ;
CVF_ASSERT ( proj ) ;
RimOilField * oilField = proj - > activeOilField ( ) ;
if ( oilField = = nullptr ) return options ;
if ( fieldNeedingOptions = = & m_fractureTemplate )
{
2017-02-07 04:08:56 -06:00
RimFractureTemplateCollection * fracDefColl = oilField - > fractureDefinitionCollection ( ) ;
2017-01-19 03:43:23 -06:00
if ( fracDefColl = = nullptr ) return options ;
2017-02-07 02:09:00 -06:00
for ( RimFractureTemplate * fracDef : fracDefColl - > fractureDefinitions ( ) )
2017-01-19 03:43:23 -06:00
{
options . push_back ( caf : : PdmOptionItemInfo ( fracDef - > name ( ) , fracDef ) ) ;
}
}
2017-02-15 05:16:01 -06:00
else if ( fieldNeedingOptions = = & stimPlanTimeIndexToPlot )
{
2017-06-09 10:21:59 -05:00
if ( fractureTemplate ( ) )
2017-02-15 05:16:01 -06:00
{
2017-06-09 10:21:59 -05:00
RimFractureTemplate * fracTemplate = fractureTemplate ( ) ;
2017-02-15 05:16:01 -06:00
if ( dynamic_cast < RimStimPlanFractureTemplate * > ( fracTemplate ) )
{
RimStimPlanFractureTemplate * fracTemplateStimPlan = dynamic_cast < RimStimPlanFractureTemplate * > ( fracTemplate ) ;
2017-06-13 04:38:22 -05:00
std : : vector < double > timeValues = fracTemplateStimPlan - > timeSteps ( ) ;
2017-02-15 05:16:01 -06:00
int index = 0 ;
for ( double value : timeValues )
{
options . push_back ( caf : : PdmOptionItemInfo ( QString : : number ( value ) , index ) ) ;
index + + ;
}
}
}
}
2017-01-19 03:43:23 -06:00
return options ;
}
2017-01-10 03:53:54 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFracture : : defineUiOrdering ( QString uiConfigName , caf : : PdmUiOrdering & uiOrdering )
{
2017-06-20 07:46:58 -05:00
if ( m_fractureUnit ( ) = = RiaEclipseUnitTools : : UNITS_METRIC )
2017-06-08 02:15:50 -05:00
{
wellDiameter . uiCapability ( ) - > setUiName ( " Well Diameter [m] " ) ;
2017-06-08 04:00:35 -05:00
perforationLength . uiCapability ( ) - > setUiName ( " Perforation Length [m] " ) ;
2017-06-08 02:15:50 -05:00
}
2017-06-20 07:46:58 -05:00
else if ( m_fractureUnit ( ) = = RiaEclipseUnitTools : : UNITS_FIELD )
2017-06-08 02:15:50 -05:00
{
wellDiameter . uiCapability ( ) - > setUiName ( " Well Diameter [inches] " ) ;
2017-06-08 04:00:35 -05:00
perforationLength . uiCapability ( ) - > setUiName ( " Perforation Length [Ft] " ) ;
2017-06-08 02:15:50 -05:00
}
2017-06-09 10:21:59 -05:00
if ( fractureTemplate ( ) )
2017-02-15 05:16:01 -06:00
{
2017-06-27 07:11:55 -05:00
if ( fractureTemplate ( ) - > orientationType = = RimFractureTemplate : : ALONG_WELL_PATH
| | fractureTemplate ( ) - > orientationType = = RimFractureTemplate : : TRANSVERSE_WELL_PATH )
{
2017-06-29 03:34:20 -05:00
m_uiWellPathAzimuth . uiCapability ( ) - > setUiHidden ( true ) ;
m_uiWellFractureAzimuthDiff . uiCapability ( ) - > setUiHidden ( true ) ;
2017-06-27 07:11:55 -05:00
m_wellFractureAzimuthAngleWarning . uiCapability ( ) - > setUiHidden ( true ) ;
}
else if ( fractureTemplate ( ) - > orientationType = = RimFractureTemplate : : AZIMUTH )
{
2017-06-29 03:34:20 -05:00
m_uiWellPathAzimuth . uiCapability ( ) - > setUiHidden ( false ) ;
m_uiWellFractureAzimuthDiff . uiCapability ( ) - > setUiHidden ( false ) ;
if ( wellFractureAzimuthDiff ( ) < 10
| | ( wellFractureAzimuthDiff ( ) > 170 & & wellFractureAzimuthDiff ( ) < 190 )
| | wellFractureAzimuthDiff ( ) > 350 )
2017-06-27 07:11:55 -05:00
{
2017-06-29 03:34:20 -05:00
m_wellFractureAzimuthAngleWarning . uiCapability ( ) - > setUiHidden ( false ) ;
2017-06-27 07:11:55 -05:00
}
else
{
2017-06-29 03:34:20 -05:00
m_wellFractureAzimuthAngleWarning . uiCapability ( ) - > setUiHidden ( true ) ;
2017-06-27 07:11:55 -05:00
}
}
2017-06-09 10:21:59 -05:00
if ( fractureTemplate ( ) - > orientationType = = RimFractureTemplate : : ALONG_WELL_PATH
| | fractureTemplate ( ) - > orientationType = = RimFractureTemplate : : TRANSVERSE_WELL_PATH )
2017-02-15 05:16:01 -06:00
{
azimuth . uiCapability ( ) - > setUiReadOnly ( true ) ;
}
2017-06-09 10:21:59 -05:00
else if ( fractureTemplate ( ) - > orientationType = = RimFractureTemplate : : AZIMUTH )
2017-02-15 05:16:01 -06:00
{
azimuth . uiCapability ( ) - > setUiReadOnly ( false ) ;
}
2017-06-09 10:21:59 -05:00
if ( fractureTemplate ( ) - > orientationType = = RimFractureTemplate : : ALONG_WELL_PATH )
2017-06-02 08:34:37 -05:00
{
perforationEfficiency . uiCapability ( ) - > setUiHidden ( false ) ;
perforationLength . uiCapability ( ) - > setUiHidden ( false ) ;
}
else
{
perforationEfficiency . uiCapability ( ) - > setUiHidden ( true ) ;
perforationLength . uiCapability ( ) - > setUiHidden ( true ) ;
}
2017-06-26 03:43:14 -05:00
if ( fractureTemplate ( ) - > conductivityType = = RimFractureTemplate : : FINITE_CONDUCTIVITY )
{
wellDiameter . uiCapability ( ) - > setUiHidden ( false ) ;
}
else if ( fractureTemplate ( ) - > conductivityType = = RimFractureTemplate : : INFINITE_CONDUCTIVITY )
{
wellDiameter . uiCapability ( ) - > setUiHidden ( true ) ;
}
2017-06-09 10:21:59 -05:00
RimFractureTemplate * fracTemplate = fractureTemplate ( ) ;
2017-02-15 05:16:01 -06:00
if ( dynamic_cast < RimStimPlanFractureTemplate * > ( fracTemplate ) )
{
stimPlanTimeIndexToPlot . uiCapability ( ) - > setUiHidden ( false ) ;
2017-04-07 04:02:31 -05:00
stimPlanTimeIndexToPlot . uiCapability ( ) - > setUiReadOnly ( true ) ;
2017-02-15 05:16:01 -06:00
}
else
{
stimPlanTimeIndexToPlot . uiCapability ( ) - > setUiHidden ( true ) ;
}
}
else
{
stimPlanTimeIndexToPlot . uiCapability ( ) - > setUiHidden ( true ) ;
}
2017-01-10 03:53:54 -06:00
}
2017-01-10 06:37:50 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFracture : : defineEditorAttribute ( const caf : : PdmFieldHandle * field , QString uiConfigName , caf : : PdmUiEditorAttribute * attribute )
{
if ( field = = & azimuth )
{
caf : : PdmUiDoubleSliderEditorAttribute * myAttr = dynamic_cast < caf : : PdmUiDoubleSliderEditorAttribute * > ( attribute ) ;
if ( myAttr )
{
myAttr - > m_minimum = 0 ;
myAttr - > m_maximum = 360 ;
}
}
2017-04-18 08:23:26 -05:00
if ( field = = & perforationEfficiency )
{
caf : : PdmUiDoubleSliderEditorAttribute * myAttr = dynamic_cast < caf : : PdmUiDoubleSliderEditorAttribute * > ( attribute ) ;
if ( myAttr )
{
myAttr - > m_minimum = 0 ;
myAttr - > m_maximum = 1.0 ;
}
}
2017-01-10 06:37:50 -06:00
}
2017-02-15 04:29:44 -06:00
//--------------------------------------------------------------------------------------------------
2017-01-19 03:43:23 -06:00
///
//--------------------------------------------------------------------------------------------------
void RimFracture : : setAnchorPosition ( const cvf : : Vec3d & pos )
{
m_anchorPosition = pos ;
2017-06-12 05:45:09 -05:00
clearDisplayGeometryCache ( ) ;
2017-01-19 03:43:23 -06:00
2017-06-16 07:13:42 -05:00
}
2017-01-19 03:43:23 -06:00
2017-06-20 07:46:58 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaEclipseUnitTools : : UnitSystem RimFracture : : fractureUnit ( ) const
{
return m_fractureUnit ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFracture : : setFractureUnit ( RiaEclipseUnitTools : : UnitSystem unitSystem )
{
m_fractureUnit = unitSystem ;
}
2017-06-20 04:18:19 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-06-20 09:40:32 -05:00
bool RimFracture : : isEclipseCellWithinContainment ( const RigMainGrid * mainGrid , size_t globalCellIndex ) const
2017-06-20 04:18:19 -05:00
{
CVF_ASSERT ( fractureTemplate ( ) ) ;
if ( ! fractureTemplate ( ) - > fractureContainment ( ) - > isEnabled ( ) ) return true ;
size_t anchorEclipseCell = findAnchorEclipseCell ( mainGrid ) ;
return fractureTemplate ( ) - > fractureContainment ( ) - > isEclipseCellWithinContainment ( mainGrid , anchorEclipseCell , globalCellIndex ) ;
}
2017-06-16 07:13:42 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimFracture : : findAnchorEclipseCell ( const RigMainGrid * mainGrid ) const
{
cvf : : BoundingBox pointBBox ;
pointBBox . add ( m_anchorPosition ) ;
2017-01-19 03:43:23 -06:00
2017-06-16 07:13:42 -05:00
std : : vector < size_t > cellIndices ;
mainGrid - > findIntersectingCells ( pointBBox , & cellIndices ) ;
size_t cellContainingAchorPoint = cvf : : UNDEFINED_SIZE_T ;
2017-01-19 03:43:23 -06:00
2017-06-16 07:13:42 -05:00
for ( size_t cellIndex : cellIndices )
{
auto cornerIndices = mainGrid - > globalCellArray ( ) [ cellIndex ] . cornerIndices ( ) ;
cvf : : Vec3d vertices [ 8 ] ;
vertices [ 0 ] = ( mainGrid - > nodes ( ) [ cornerIndices [ 0 ] ] ) ;
vertices [ 1 ] = ( mainGrid - > nodes ( ) [ cornerIndices [ 1 ] ] ) ;
vertices [ 2 ] = ( mainGrid - > nodes ( ) [ cornerIndices [ 2 ] ] ) ;
vertices [ 3 ] = ( mainGrid - > nodes ( ) [ cornerIndices [ 3 ] ] ) ;
vertices [ 4 ] = ( mainGrid - > nodes ( ) [ cornerIndices [ 4 ] ] ) ;
vertices [ 5 ] = ( mainGrid - > nodes ( ) [ cornerIndices [ 5 ] ] ) ;
vertices [ 6 ] = ( mainGrid - > nodes ( ) [ cornerIndices [ 6 ] ] ) ;
vertices [ 7 ] = ( mainGrid - > nodes ( ) [ cornerIndices [ 7 ] ] ) ;
if ( RigHexIntersectionTools : : isPointInCell ( m_anchorPosition , vertices ) )
2017-01-19 03:43:23 -06:00
{
2017-06-16 07:13:42 -05:00
cellContainingAchorPoint = cellIndex ;
break ;
2017-01-19 03:43:23 -06:00
}
2017-06-16 07:13:42 -05:00
}
return cellContainingAchorPoint ;
2017-01-19 03:43:23 -06:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-02-07 02:09:00 -06:00
void RimFracture : : setFractureTemplate ( RimFractureTemplate * fractureTemplate )
2017-01-19 03:43:23 -06:00
{
m_fractureTemplate = fractureTemplate ;
2017-02-23 02:22:19 -06:00
2017-06-09 10:21:59 -05:00
RimStimPlanFractureTemplate * stimPlanFracTemplate = dynamic_cast < RimStimPlanFractureTemplate * > ( fractureTemplate ) ;
2017-02-23 02:22:19 -06:00
if ( stimPlanFracTemplate )
{
2017-06-12 07:42:35 -05:00
stimPlanTimeIndexToPlot = stimPlanFracTemplate - > activeTimeStepIndex ( ) ;
2017-02-23 02:22:19 -06:00
}
2017-06-29 08:06:44 -05:00
if ( fractureTemplate - > orientationType = = RimFractureTemplate : : AZIMUTH )
{
azimuth = fractureTemplate - > azimuthAngle ;
}
else
{
this - > updateAzimuthBasedOnWellAzimuthAngle ( ) ;
}
2017-06-20 07:46:58 -05:00
this - > wellDiameter = fractureTemplate - > wellDiameterInFractureUnit ( m_fractureUnit ( ) ) ;
this - > perforationLength = fractureTemplate - > perforationLengthInFractureUnit ( m_fractureUnit ( ) ) ;
2017-01-19 03:43:23 -06:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-06-09 10:21:59 -05:00
RimFractureTemplate * RimFracture : : fractureTemplate ( ) const
2017-01-19 03:43:23 -06:00
{
return m_fractureTemplate ( ) ;
}
2017-01-19 00:28:04 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivWellFracturePartMgr * RimFracture : : fracturePartManager ( )
{
2017-06-09 10:21:59 -05:00
CVF_ASSERT ( m_fracturePartMgr . notNull ( ) ) ;
2017-01-19 00:28:04 -06:00
2017-06-09 10:21:59 -05:00
return m_fracturePartMgr . p ( ) ;
2017-01-19 00:28:04 -06:00
}