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-12-20 06:14:43 -06:00
# include "RimStimPlanColors.h"
2018-01-09 03:11:28 -06:00
# include "Rim3dView.h"
2017-01-10 06:37:50 -06:00
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
2018-02-19 07:32:33 -06:00
# include <QMessageBox>
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
2017-12-20 06:14:43 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void setDefaultFractureColorResult ( )
{
RiaApplication * app = RiaApplication : : instance ( ) ;
RimProject * proj = app - > project ( ) ;
for ( RimEclipseCase * const eclCase : proj - > eclipseCases ( ) )
{
2018-01-09 03:11:28 -06:00
for ( Rim3dView * const view : eclCase - > views ( ) )
2017-12-20 06:14:43 -06:00
{
std : : vector < RimStimPlanColors * > fractureColors ;
view - > descendantsIncludingThisOfType ( fractureColors ) ;
for ( RimStimPlanColors * const stimPlanColors : fractureColors )
{
2018-02-06 05:57:50 -06:00
stimPlanColors - > setDefaultResultName ( ) ;
2017-12-20 06:14:43 -06:00
}
}
}
}
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 ) ;
2018-01-10 07:43:01 -06:00
m_anchorPosition . xmlCapability ( ) - > disableIO ( ) ;
2017-01-19 03:43:23 -06:00
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
2018-01-12 03:21:10 -06:00
CAF_PDM_InitField ( & m_azimuth , " Azimuth " , 0.0 , " Azimuth " , " " , " " , " " ) ;
m_azimuth . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiDoubleSliderEditor : : uiEditorTypeName ( ) ) ;
2017-06-16 07:13:42 -05:00
2018-01-12 03:21:10 -06:00
CAF_PDM_InitField ( & m_perforationLength , " PerforationLength " , 1.0 , " Perforation Length " , " " , " " , " " ) ;
CAF_PDM_InitField ( & m_perforationEfficiency , " PerforationEfficiency " , 1.0 , " Perforation Efficiency " , " " , " " , " " ) ;
m_perforationEfficiency . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiDoubleSliderEditor : : uiEditorTypeName ( ) ) ;
2017-06-16 07:13:42 -05:00
2018-01-12 03:21:10 -06:00
CAF_PDM_InitField ( & m_wellDiameter , " WellDiameter " , 0.216 , " Well Diameter at Fracture " , " " , " " , " " ) ;
CAF_PDM_InitField ( & m_dip , " Dip " , 0.0 , " Dip " , " " , " " , " " ) ;
CAF_PDM_InitField ( & m_tilt , " Tilt " , 0.0 , " Tilt " , " " , " " , " " ) ;
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
2018-01-12 03:21:10 -06:00
CAF_PDM_InitField ( & m_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
2018-01-12 03:21:10 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimFracture : : perforationLength ( ) const
{
return m_perforationLength ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimFracture : : perforationEfficiency ( ) const
{
return m_perforationEfficiency ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFracture : : setStimPlanTimeIndexToPlot ( int timeIndex )
{
m_stimPlanTimeIndexToPlot = timeIndex ;
}
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 )
{
2018-02-19 07:32:33 -06:00
if ( fractureUnit ( ) ! = m_fractureTemplate - > fractureTemplateUnit ( ) )
{
QString fractureUnitText = RiaEclipseUnitTools : : UnitSystemType : : uiText ( fractureUnit ( ) ) ;
QString warningText = QString ( " Using a fracture template of different unit is not supported. \n \n Please select a "
" fracture template of unit '%1' " )
. arg ( fractureUnitText ) ;
QMessageBox : : warning ( nullptr , " Fracture Template Selection " , warningText ) ;
m_fractureTemplate = nullptr ;
}
2017-06-15 03:49:27 -05:00
setFractureTemplate ( m_fractureTemplate ) ;
2017-12-20 06:14:43 -06:00
setDefaultFractureColorResult ( ) ;
2017-01-23 02:46:33 -06:00
}
2018-01-12 03:21:10 -06:00
if ( changedField = = & m_azimuth | |
2017-02-15 08:49:53 -06:00
changedField = = & m_fractureTemplate | |
2018-01-12 03:21:10 -06:00
changedField = = & m_stimPlanTimeIndexToPlot | |
2017-02-28 07:28:14 -06:00
changedField = = this - > objectToggleField ( ) | |
2018-01-12 03:21:10 -06:00
changedField = = & m_dip | |
2018-01-19 08:08:28 -06:00
changedField = = & m_tilt | |
changedField = = & m_perforationLength )
2017-01-10 06:37:50 -06:00
{
2018-01-09 03:11:28 -06:00
Rim3dView * rimView = nullptr ;
2017-01-10 06:37:50 -06:00
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
{
2018-01-12 03:21:10 -06:00
double wellDifference = fabs ( wellAzimuthAtFracturePosition ( ) - m_azimuth ) ;
2017-06-29 03:34:20 -05:00
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 ;
2018-01-12 03:25:16 -06:00
for ( const auto & nodeCoord : nodeCoordVec ) fractureBBox . add ( nodeCoord ) ;
2017-06-12 05:45:09 -05:00
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 )
{
2018-01-12 03:21:10 -06:00
return RiaEclipseUnitTools : : meterToFeet ( m_wellDiameter / 2 ) ;
2017-06-20 07:46:58 -05:00
}
else
{
2018-01-12 03:21:10 -06:00
return m_wellDiameter / 2 ;
2017-06-20 07:46:58 -05:00
}
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 )
{
2018-01-12 03:21:10 -06:00
return RiaEclipseUnitTools : : inchToMeter ( m_wellDiameter / 2 ) ;
2017-06-20 07:46:58 -05:00
}
else
{
2018-01-12 03:21:10 -06:00
return RiaEclipseUnitTools : : inchToFeet ( m_wellDiameter / 2 ) ;
2017-06-20 07:46:58 -05:00
}
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)
2018-01-12 03:21:10 -06:00
cvf : : Mat4d dipRotation = cvf : : Mat4d : : fromRotation ( cvf : : Vec3d : : Z_AXIS , cvf : : Math : : toRadians ( m_dip ( ) ) ) ;
2017-03-06 06:32:42 -06:00
2017-03-29 03:12:01 -05:00
// Dip (out of XY plane)
2018-01-12 03:21:10 -06:00
cvf : : Mat4d tiltRotation = cvf : : Mat4d : : fromRotation ( cvf : : Vec3d : : X_AXIS , cvf : : Math : : toRadians ( m_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
2018-01-12 03:21:10 -06:00
cvf : : Mat4d azimuthRotation = cvf : : Mat4d : : fromRotation ( cvf : : Vec3d : : Z_AXIS , cvf : : Math : : toRadians ( - m_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 : : triangleGeometry ( std : : vector < cvf : : uint > * triangleIndices , std : : vector < cvf : : Vec3f > * nodeCoords )
2017-01-06 06:13:25 -06:00
{
2018-01-12 03:21:10 -06:00
RimFractureTemplate * fractureDef = fractureTemplate ( ) ;
if ( fractureDef )
{
fractureDef - > fractureTriangleGeometry ( nodeCoords , triangleIndices , fractureUnit ( ) ) ;
}
2017-06-12 05:45:09 -05:00
2018-01-12 03:21:10 -06:00
cvf : : Mat4d m = transformMatrix ( ) ;
2017-06-12 05:45:09 -05:00
2018-01-12 03:21:10 -06:00
for ( cvf : : Vec3f & v : * nodeCoords )
{
cvf : : Vec3d vd ( v ) ;
2017-06-23 03:16:39 -05:00
2018-01-12 03:21:10 -06:00
vd . transformPoint ( m ) ;
2017-06-23 03:16:39 -05:00
2018-01-12 03:21:10 -06:00
v = cvf : : Vec3f ( vd ) ;
}
2017-01-04 01:10:02 -06: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
{
2018-02-19 06:54:29 -06:00
options . push_back ( caf : : PdmOptionItemInfo ( fracDef - > nameAndUnit ( ) , fracDef ) ) ;
2017-01-19 03:43:23 -06:00
}
}
2018-01-12 03:21:10 -06:00
else if ( fieldNeedingOptions = = & m_stimPlanTimeIndexToPlot )
2017-02-15 05:16:01 -06:00
{
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
{
2018-01-12 03:21:10 -06:00
m_wellDiameter . uiCapability ( ) - > setUiName ( " Well Diameter [m] " ) ;
m_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
{
2018-01-12 03:21:10 -06:00
m_wellDiameter . uiCapability ( ) - > setUiName ( " Well Diameter [inches] " ) ;
m_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
{
2018-02-08 06:57:43 -06:00
if ( fractureTemplate ( ) - > orientationType ( ) = = RimFractureTemplate : : ALONG_WELL_PATH
| | fractureTemplate ( ) - > orientationType ( ) = = RimFractureTemplate : : TRANSVERSE_WELL_PATH )
2017-06-27 07:11:55 -05:00
{
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 ) ;
}
2018-02-08 06:57:43 -06:00
else if ( fractureTemplate ( ) - > orientationType ( ) = = RimFractureTemplate : : AZIMUTH )
2017-06-27 07:11:55 -05:00
{
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
}
}
2018-02-08 06:57:43 -06:00
if ( fractureTemplate ( ) - > orientationType ( ) = = RimFractureTemplate : : ALONG_WELL_PATH
| | fractureTemplate ( ) - > orientationType ( ) = = RimFractureTemplate : : TRANSVERSE_WELL_PATH )
2017-02-15 05:16:01 -06:00
{
2018-01-12 03:21:10 -06:00
m_azimuth . uiCapability ( ) - > setUiReadOnly ( true ) ;
2017-02-15 05:16:01 -06:00
}
2018-02-08 06:57:43 -06:00
else if ( fractureTemplate ( ) - > orientationType ( ) = = RimFractureTemplate : : AZIMUTH )
2017-02-15 05:16:01 -06:00
{
2018-01-12 03:21:10 -06:00
m_azimuth . uiCapability ( ) - > setUiReadOnly ( false ) ;
2017-02-15 05:16:01 -06:00
}
2018-02-08 06:57:43 -06:00
if ( fractureTemplate ( ) - > orientationType ( ) = = RimFractureTemplate : : ALONG_WELL_PATH )
2017-06-02 08:34:37 -05:00
{
2018-01-12 03:21:10 -06:00
m_perforationEfficiency . uiCapability ( ) - > setUiHidden ( false ) ;
m_perforationLength . uiCapability ( ) - > setUiHidden ( false ) ;
2017-06-02 08:34:37 -05:00
}
else
{
2018-01-12 03:21:10 -06:00
m_perforationEfficiency . uiCapability ( ) - > setUiHidden ( true ) ;
m_perforationLength . uiCapability ( ) - > setUiHidden ( true ) ;
2017-06-02 08:34:37 -05:00
}
2018-02-08 04:34:18 -06:00
if ( fractureTemplate ( ) - > conductivityType ( ) = = RimFractureTemplate : : FINITE_CONDUCTIVITY )
2017-06-26 03:43:14 -05:00
{
2018-01-12 03:21:10 -06:00
m_wellDiameter . uiCapability ( ) - > setUiHidden ( false ) ;
2017-06-26 03:43:14 -05:00
}
2018-02-08 04:34:18 -06:00
else if ( fractureTemplate ( ) - > conductivityType ( ) = = RimFractureTemplate : : INFINITE_CONDUCTIVITY )
2017-06-26 03:43:14 -05:00
{
2018-01-12 03:21:10 -06:00
m_wellDiameter . uiCapability ( ) - > setUiHidden ( true ) ;
2017-06-26 03:43:14 -05: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 ) )
{
2018-01-12 03:21:10 -06:00
m_stimPlanTimeIndexToPlot . uiCapability ( ) - > setUiHidden ( false ) ;
2018-01-12 06:20:54 -06:00
2018-01-12 03:21:10 -06:00
m_stimPlanTimeIndexToPlot . uiCapability ( ) - > setUiReadOnly ( true ) ;
2017-02-15 05:16:01 -06:00
}
else
{
2018-01-12 03:21:10 -06:00
m_stimPlanTimeIndexToPlot . uiCapability ( ) - > setUiHidden ( true ) ;
2017-02-15 05:16:01 -06:00
}
}
else
{
2018-01-12 03:21:10 -06:00
m_stimPlanTimeIndexToPlot . uiCapability ( ) - > setUiHidden ( true ) ;
2017-02-15 05:16:01 -06:00
}
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 )
{
2018-01-12 03:21:10 -06:00
if ( field = = & m_azimuth )
2017-01-10 06:37:50 -06:00
{
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
2018-01-12 03:21:10 -06:00
if ( field = = & m_perforationEfficiency )
2017-04-18 08:23:26 -05:00
{
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-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
2018-01-03 04:50:34 -06:00
if ( ! fractureTemplate )
{
return ;
}
2017-06-09 10:21:59 -05:00
RimStimPlanFractureTemplate * stimPlanFracTemplate = dynamic_cast < RimStimPlanFractureTemplate * > ( fractureTemplate ) ;
2017-02-23 02:22:19 -06:00
if ( stimPlanFracTemplate )
{
2018-01-12 03:21:10 -06:00
m_stimPlanTimeIndexToPlot = stimPlanFracTemplate - > activeTimeStepIndex ( ) ;
2017-02-23 02:22:19 -06:00
}
2018-02-08 06:57:43 -06:00
if ( fractureTemplate - > orientationType ( ) = = RimFractureTemplate : : AZIMUTH )
2017-06-29 08:06:44 -05:00
{
2018-02-08 04:34:18 -06:00
m_azimuth = fractureTemplate - > azimuthAngle ( ) ;
2017-06-29 08:06:44 -05:00
}
else
{
this - > updateAzimuthBasedOnWellAzimuthAngle ( ) ;
}
2018-01-12 03:21:10 -06:00
this - > m_wellDiameter = fractureTemplate - > wellDiameterInFractureUnit ( m_fractureUnit ( ) ) ;
this - > m_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
}