2017-02-07 02:09:00 -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 "RimFractureTemplate.h"
# include "RigTesselatorTools.h"
# include "RimFracture.h"
# include "RimProject.h"
# include "cafPdmObject.h"
2017-04-19 04:00:52 -05:00
# include "cafPdmUiDoubleSliderEditor.h"
2017-02-07 02:09:00 -06:00
# include "cvfVector3.h"
2017-06-08 15:54:06 -05:00
# include "RimFractureContainment.h"
2017-02-07 02:09:00 -06:00
namespace caf
{
template < >
void caf : : AppEnum < RimFractureTemplate : : FracOrientationEnum > : : setUp ( )
{
addItem ( RimFractureTemplate : : AZIMUTH , " Az " , " Azimuth " ) ;
addItem ( RimFractureTemplate : : ALONG_WELL_PATH , " AlongWellPath " , " Along Well Path " ) ;
addItem ( RimFractureTemplate : : TRANSVERSE_WELL_PATH , " TransverseWellPath " , " Transverse (normal) to Well Path " ) ;
setDefault ( RimFractureTemplate : : TRANSVERSE_WELL_PATH ) ;
}
2017-02-10 06:29:31 -06:00
2017-02-10 06:43:22 -06:00
template < >
2017-02-10 06:29:31 -06:00
void caf : : AppEnum < RimFractureTemplate : : FracConductivityEnum > : : setUp ( )
{
2017-02-22 04:52:06 -06:00
addItem ( RimFractureTemplate : : INFINITE_CONDUCTIVITY , " InfiniteConductivity " , " Infinite Conductivity " ) ;
addItem ( RimFractureTemplate : : FINITE_CONDUCTIVITY , " FiniteConductivity " , " Finite Conductivity " ) ;
2017-02-10 06:29:31 -06:00
setDefault ( RimFractureTemplate : : INFINITE_CONDUCTIVITY ) ;
}
2017-02-14 02:49:14 -06:00
2017-02-07 02:09:00 -06:00
}
CAF_PDM_XML_ABSTRACT_SOURCE_INIT ( RimFractureTemplate , " RimFractureTemplate " ) ;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFractureTemplate : : RimFractureTemplate ( void )
{
CAF_PDM_InitObject ( " Fracture Template " , " :/FractureTemplate16x16.png " , " " , " " ) ;
CAF_PDM_InitField ( & name , " UserDescription " , QString ( " Fracture Template " ) , " Name " , " " , " " , " " ) ;
2017-06-14 00:25:34 -05:00
CAF_PDM_InitField ( & fractureTemplateUnit , " fractureTemplateUnit " , caf : : AppEnum < RiaEclipseUnitTools : : UnitSystem > ( RiaEclipseUnitTools : : UNITS_METRIC ) , " Units System " , " " , " " , " " ) ;
2017-02-14 02:49:14 -06:00
fractureTemplateUnit . uiCapability ( ) - > setUiReadOnly ( true ) ;
2017-06-09 10:21:59 -05:00
CAF_PDM_InitField ( & orientationType , " Orientation " , caf : : AppEnum < FracOrientationEnum > ( TRANSVERSE_WELL_PATH ) , " Fracture Orientation " , " " , " " , " " ) ;
2017-02-07 02:09:00 -06:00
CAF_PDM_InitField ( & azimuthAngle , " AzimuthAngle " , 0.0f , " Azimuth Angle " , " " , " " , " " ) ; //Is this correct description?
2017-06-15 04:23:25 -05:00
CAF_PDM_InitField ( & skinFactor , " SkinFactor " , 0.0f , " Skin Factor " , " " , " " , " " ) ;
2017-02-10 06:29:31 -06:00
2017-06-08 04:00:35 -05:00
CAF_PDM_InitField ( & perforationLength , " PerforationLength " , 1.0 , " Perforation Length " , " " , " " , " " ) ;
2017-04-19 04:00:52 -05:00
CAF_PDM_InitField ( & perforationEfficiency , " perforationEfficiency " , 1.0 , " perforation Efficiency " , " " , " " , " " ) ;
perforationEfficiency . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiDoubleSliderEditor : : uiEditorTypeName ( ) ) ;
2017-06-08 02:15:50 -05:00
CAF_PDM_InitField ( & wellDiameter , " wellDiameter " , 0.216 , " Well Diameter at Fracture " , " " , " " , " " ) ;
2017-04-19 04:00:52 -05:00
2017-06-09 10:21:59 -05:00
CAF_PDM_InitField ( & conductivityType , " FractureCondictivity " , caf : : AppEnum < FracConductivityEnum > ( FINITE_CONDUCTIVITY ) , " Conductivity in Fracture " , " " , " " , " " ) ;
2017-02-10 06:29:31 -06:00
2017-06-09 10:21:59 -05:00
CAF_PDM_InitFieldNoDefault ( & m_fractureContainment , " fractureContainmentField " , " Fracture Containment " , " " , " " , " " ) ;
m_fractureContainment = new RimFractureContainment ( ) ;
m_fractureContainment . uiCapability ( ) - > setUiTreeHidden ( true ) ;
m_fractureContainment . uiCapability ( ) - > setUiTreeChildrenHidden ( true ) ;
2017-02-07 02:09:00 -06:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFractureTemplate : : ~ RimFractureTemplate ( )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf : : PdmFieldHandle * RimFractureTemplate : : userDescriptionField ( )
{
return & name ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFractureTemplate : : fieldChangedByUi ( const caf : : PdmFieldHandle * changedField , const QVariant & oldValue , const QVariant & newValue )
{
2017-06-09 10:21:59 -05:00
if ( changedField = = & azimuthAngle | | changedField = = & orientationType )
2017-02-23 02:47:30 -06:00
{
//Changes to one of these parameters should change all fractures with this fracture template attached.
RimProject * proj ;
this - > firstAncestorOrThisOfType ( proj ) ;
if ( proj )
{
//Regenerate geometry
std : : vector < RimFracture * > fractures ;
proj - > descendantsIncludingThisOfType ( fractures ) ;
for ( RimFracture * fracture : fractures )
{
2017-06-09 10:21:59 -05:00
if ( fracture - > fractureTemplate ( ) = = this )
2017-02-23 02:47:30 -06:00
{
if ( changedField = = & azimuthAngle & & ( abs ( oldValue . toDouble ( ) - fracture - > azimuth ( ) ) < 1e-5 ) )
{
2017-06-29 08:06:44 -05:00
fracture - > azimuth = azimuthAngle ;
2017-06-12 05:45:09 -05:00
fracture - > clearDisplayGeometryCache ( ) ;
2017-02-23 02:47:30 -06:00
}
2017-06-09 10:21:59 -05:00
if ( changedField = = & orientationType )
2017-02-23 02:47:30 -06:00
{
2017-06-29 08:06:44 -05:00
if ( newValue = = AZIMUTH )
{
fracture - > azimuth = azimuthAngle ;
}
else fracture - > updateAzimuthBasedOnWellAzimuthAngle ( ) ;
2017-02-23 02:47:30 -06:00
2017-06-12 05:45:09 -05:00
fracture - > clearDisplayGeometryCache ( ) ;
2017-02-23 02:47:30 -06:00
}
}
}
proj - > createDisplayModelAndRedrawAllViews ( ) ;
}
}
2017-02-07 02:09:00 -06:00
2017-06-08 02:15:50 -05:00
if ( changedField = = & perforationLength | | changedField = = & perforationEfficiency | | changedField = = & wellDiameter )
2017-04-19 04:00:52 -05:00
{
RimProject * proj ;
this - > firstAncestorOrThisOfType ( proj ) ;
if ( ! proj ) return ;
std : : vector < RimFracture * > fractures ;
proj - > descendantsIncludingThisOfType ( fractures ) ;
for ( RimFracture * fracture : fractures )
{
2017-06-09 10:21:59 -05:00
if ( fracture - > fractureTemplate ( ) = = this )
2017-04-19 04:00:52 -05:00
{
if ( changedField = = & perforationLength & & ( abs ( oldValue . toDouble ( ) - fracture - > perforationLength ( ) ) < 1e-5 ) )
{
fracture - > perforationLength = perforationLength ;
}
if ( changedField = = & perforationEfficiency & & ( abs ( oldValue . toDouble ( ) - fracture - > perforationEfficiency ( ) ) < 1e-5 ) )
{
fracture - > perforationEfficiency = perforationEfficiency ;
}
2017-06-08 02:15:50 -05:00
if ( changedField = = & wellDiameter & & ( abs ( oldValue . toDouble ( ) - fracture - > wellDiameter ( ) ) < 1e-5 ) )
2017-04-19 04:00:52 -05:00
{
2017-06-08 02:15:50 -05:00
fracture - > wellDiameter = wellDiameter ;
2017-04-19 04:00:52 -05:00
}
}
}
}
}
2017-02-07 02:09:00 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFractureTemplate : : defineUiOrdering ( QString uiConfigName , caf : : PdmUiOrdering & uiOrdering )
{
2017-02-14 02:49:14 -06:00
2017-06-14 00:25:34 -05:00
if ( fractureTemplateUnit = = RiaEclipseUnitTools : : UNITS_METRIC )
2017-06-08 04:00:35 -05:00
{
wellDiameter . uiCapability ( ) - > setUiName ( " Well Diameter [m] " ) ;
perforationLength . uiCapability ( ) - > setUiName ( " Perforation Length [m] " ) ;
}
2017-06-14 00:25:34 -05:00
else if ( fractureTemplateUnit = = RiaEclipseUnitTools : : UNITS_FIELD )
2017-06-08 04:00:35 -05:00
{
wellDiameter . uiCapability ( ) - > setUiName ( " Well Diameter [inches] " ) ;
perforationLength . uiCapability ( ) - > setUiName ( " Perforation Length [Ft] " ) ;
}
2017-06-09 10:21:59 -05:00
if ( orientationType = = RimFractureTemplate : : ALONG_WELL_PATH
| | orientationType = = RimFractureTemplate : : TRANSVERSE_WELL_PATH )
2017-02-10 03:33:07 -06:00
{
azimuthAngle . uiCapability ( ) - > setUiHidden ( true ) ;
}
2017-06-09 10:21:59 -05:00
else if ( orientationType = = RimFractureTemplate : : AZIMUTH )
2017-02-10 03:33:07 -06:00
{
azimuthAngle . uiCapability ( ) - > setUiHidden ( false ) ;
}
2017-06-02 08:34:37 -05:00
2017-06-09 10:21:59 -05:00
if ( 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 ( conductivityType = = FINITE_CONDUCTIVITY )
{
wellDiameter . uiCapability ( ) - > setUiHidden ( false ) ;
}
else if ( conductivityType = = INFINITE_CONDUCTIVITY )
{
wellDiameter . uiCapability ( ) - > setUiHidden ( true ) ;
}
2017-06-08 15:54:06 -05:00
2017-02-07 02:09:00 -06:00
}
2017-04-19 04:00:52 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFractureTemplate : : defineEditorAttribute ( const caf : : PdmFieldHandle * field , QString uiConfigName , caf : : PdmUiEditorAttribute * attribute )
{
if ( field = = & perforationEfficiency )
{
caf : : PdmUiDoubleSliderEditorAttribute * myAttr = dynamic_cast < caf : : PdmUiDoubleSliderEditorAttribute * > ( attribute ) ;
if ( myAttr )
{
myAttr - > m_minimum = 0 ;
myAttr - > m_maximum = 1.0 ;
}
}
}
2017-06-08 02:15:50 -05:00
2017-06-15 03:49:27 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimFractureTemplate : : wellDiameterInFractureUnit ( RiaEclipseUnitTools : : UnitSystemType fractureUnit )
{
if ( fractureUnit = = fractureTemplateUnit ( ) )
{
return wellDiameter ;
}
else if ( fractureTemplateUnit = = RiaEclipseUnitTools : : UNITS_METRIC
& & fractureUnit = = RiaEclipseUnitTools : : UNITS_FIELD )
{
return RiaEclipseUnitTools : : meterToInch ( wellDiameter ) ;
}
else if ( fractureTemplateUnit = = RiaEclipseUnitTools : : UNITS_FIELD
& & fractureUnit = = RiaEclipseUnitTools : : UNITS_METRIC )
{
return RiaEclipseUnitTools : : inchToMeter ( wellDiameter ) ;
}
return cvf : : UNDEFINED_DOUBLE ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimFractureTemplate : : perforationLengthInFractureUnit ( RiaEclipseUnitTools : : UnitSystemType fractureUnit )
{
if ( fractureUnit = = fractureTemplateUnit ( ) )
{
return perforationLength ;
}
else if ( fractureTemplateUnit = = RiaEclipseUnitTools : : UNITS_METRIC
& & fractureUnit = = RiaEclipseUnitTools : : UNITS_FIELD )
{
return RiaEclipseUnitTools : : meterToFeet ( perforationLength ) ;
}
else if ( fractureTemplateUnit = = RiaEclipseUnitTools : : UNITS_FIELD
& & fractureUnit = = RiaEclipseUnitTools : : UNITS_METRIC )
{
return RiaEclipseUnitTools : : feetToMeter ( perforationLength ) ;
}
return cvf : : UNDEFINED_DOUBLE ;
}
2017-06-20 04:18:19 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RimFractureContainment * RimFractureTemplate : : fractureContainment ( )
{
return m_fractureContainment ( ) ;
}
2017-06-08 02:15:50 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFractureTemplate : : setDefaultWellDiameterFromUnit ( )
{
2017-06-14 00:25:34 -05:00
if ( fractureTemplateUnit = = RiaEclipseUnitTools : : UNITS_FIELD )
2017-06-08 02:15:50 -05:00
{
wellDiameter = 8.5 ;
}
2017-06-14 00:25:34 -05:00
else if ( fractureTemplateUnit = = RiaEclipseUnitTools : : UNITS_METRIC )
2017-06-08 02:15:50 -05:00
{
wellDiameter = 0.216 ;
}
}