Refactor: Introduce MeshFractureTemplate, and convert StimPlanFractureTemplate to it.

This commit is contained in:
Kristian Bendiksen 2022-06-17 22:22:44 +02:00
parent 972013c631
commit a89899b7dc
6 changed files with 705 additions and 463 deletions

View File

@ -145,7 +145,7 @@ std::vector<RimStimPlanFractureTemplate*>
fractureDef->setFileName( fileName );
fractureDef->loadDataAndUpdate();
fractureDef->setDefaultsBasedOnXMLfile();
fractureDef->setDefaultsBasedOnFile();
fractureDef->setDefaultWellDiameterFromUnit();
newFractures.push_back( fractureDef );
}

View File

@ -21,6 +21,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimValveTemplate.h
${CMAKE_CURRENT_LIST_DIR}/RimSimWellFracture.h
${CMAKE_CURRENT_LIST_DIR}/RimSimWellFractureCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimMeshFractureTemplate.h
${CMAKE_CURRENT_LIST_DIR}/RimStimPlanFractureTemplate.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPathFracture.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPathFractureCollection.h
@ -56,6 +57,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimValveTemplate.cpp
${CMAKE_CURRENT_LIST_DIR}/RimSimWellFracture.cpp
${CMAKE_CURRENT_LIST_DIR}/RimSimWellFractureCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimMeshFractureTemplate.cpp
${CMAKE_CURRENT_LIST_DIR}/RimStimPlanFractureTemplate.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathFracture.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathFractureCollection.cpp

View File

@ -0,0 +1,539 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2022 - Equinor 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 "RimMeshFractureTemplate.h"
#include "RiaApplication.h"
#include "RiaCompletionTypeCalculationScheduler.h"
#include "RiaEclipseUnitTools.h"
#include "RiaFractureDefines.h"
#include "RiaWeightedGeometricMeanCalculator.h"
#include "RiaWeightedMeanCalculator.h"
#include "RigFractureCell.h"
#include "RigFractureGrid.h"
#include "RigTransmissibilityEquations.h"
#include "RigWellPathStimplanIntersector.h"
#include "RimEclipseView.h"
#include "RimFracture.h"
#include "RimFractureContainment.h"
#include "RimProject.h"
#include "RimTools.h"
#include "RimWellPath.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObject.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiFilePathEditor.h"
#include <algorithm>
#include <cmath>
#include <vector>
CAF_PDM_ABSTRACT_SOURCE_INIT( RimMeshFractureTemplate, "MeshFractureTemplate", "RimMeshFractureTemplate" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMeshFractureTemplate::RimMeshFractureTemplate()
{
CAF_PDM_InitScriptableObject( "Fracture Template", ":/FractureTemplate16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_stimPlanFileName, "StimFileName", "File Name" );
m_stimPlanFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_userDefinedWellPathDepthAtFracture,
"UserDefinedWellPathDepthAtFracture",
false,
"User-Defined Well/Fracture Intersection Depth" );
CAF_PDM_InitField( &m_borderPolygonResultName, "BorderPolygonResultName", QString( "" ), "Parameter" );
m_borderPolygonResultName.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_activeTimeStepIndex, "ActiveTimeStepIndex", 0, "Active TimeStep Index" );
CAF_PDM_InitField( &m_conductivityResultNameOnFile,
"ConductivityResultName",
QString( "" ),
"Active Conductivity Result Name" );
m_readError = false;
setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMeshFractureTemplate::~RimMeshFractureTemplate()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimMeshFractureTemplate::activeTimeStepIndex()
{
return m_activeTimeStepIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMeshFractureTemplate::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
RimFractureTemplate::fieldChangedByUi( changedField, oldValue, newValue );
if ( &m_stimPlanFileName == changedField )
{
m_readError = false;
loadDataAndUpdate();
setDefaultsBasedOnFile();
}
if ( &m_userDefinedWellPathDepthAtFracture == changedField )
{
if ( !m_userDefinedWellPathDepthAtFracture )
{
m_readError = false;
loadDataAndUpdate();
RimProject::current()->scheduleCreateDisplayModelAndRedrawAllViews();
}
}
if ( &m_activeTimeStepIndex == changedField )
{
// Changes to this parameters should change all fractures with this fracture template attached.
RimProject* proj = RimProject::current();
for ( RimFracture* fracture : fracturesUsingThisTemplate() )
{
fracture->setStimPlanTimeIndexToPlot( m_activeTimeStepIndex );
}
proj->scheduleCreateDisplayModelAndRedrawAllViews();
}
if ( &m_borderPolygonResultName == changedField || &m_activeTimeStepIndex == changedField ||
&m_stimPlanFileName == changedField || &m_conductivityResultNameOnFile == changedField )
{
// Update fracture grid for all fractures using this template
RimProject* proj = RimProject::current();
for ( RimFracture* fracture : fracturesUsingThisTemplate() )
{
fracture->updateFractureGrid();
}
proj->scheduleCreateDisplayModelAndRedrawAllViews();
}
if ( changedField == &m_scaleApplyButton )
{
m_scaleApplyButton = false;
onLoadDataAndUpdateGeometryHasChanged();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMeshFractureTemplate::setFileName( const QString& fileName )
{
m_stimPlanFileName = fileName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimMeshFractureTemplate::fileName()
{
return m_stimPlanFileName().path();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimMeshFractureTemplate::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_fractureWidthType )
{
options.push_back(
caf::PdmOptionItemInfo( caf::AppEnum<WidthEnum>::uiText( USER_DEFINED_WIDTH ), USER_DEFINED_WIDTH ) );
if ( !widthResultValues().empty() )
{
options.push_back(
caf::PdmOptionItemInfo( caf::AppEnum<WidthEnum>::uiText( WIDTH_FROM_FRACTURE ), WIDTH_FROM_FRACTURE ) );
}
}
if ( fieldNeedingOptions == &m_betaFactorType )
{
options.push_back( caf::PdmOptionItemInfo( caf::AppEnum<BetaFactorEnum>::uiText( USER_DEFINED_BETA_FACTOR ),
USER_DEFINED_BETA_FACTOR ) );
if ( isBetaFactorAvailableOnFile() )
{
options.push_back( caf::PdmOptionItemInfo( caf::AppEnum<BetaFactorEnum>::uiText( BETA_FACTOR_FROM_FRACTURE ),
BETA_FACTOR_FROM_FRACTURE ) );
}
}
if ( fieldNeedingOptions == &m_borderPolygonResultName )
{
for ( std::pair<QString, QString> nameUnit : uiResultNamesWithUnit() )
{
options.push_back( caf::PdmOptionItemInfo( nameUnit.first, nameUnit.first ) );
}
}
else if ( fieldNeedingOptions == &m_activeTimeStepIndex )
{
std::vector<double> timeValues = timeSteps();
int index = 0;
for ( double value : timeValues )
{
options.push_back( caf::PdmOptionItemInfo( QString::number( value ), index ) );
index++;
}
}
else if ( fieldNeedingOptions == &m_conductivityResultNameOnFile )
{
QStringList resultNames = conductivityResultNames();
for ( const auto& resultName : resultNames )
{
options.push_back( caf::PdmOptionItemInfo( resultName, resultName ) );
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
WellFractureIntersectionData RimMeshFractureTemplate::wellFractureIntersectionData( const RimFracture* fractureInstance ) const
{
if ( !fractureInstance || !fractureInstance->fractureGrid() ) return {};
WellFractureIntersectionData values;
const RigFractureGrid* fractureGrid = fractureInstance->fractureGrid();
if ( orientationType() == ALONG_WELL_PATH )
{
RimWellPath* rimWellPath = nullptr;
fractureInstance->firstAncestorOrThisOfType( rimWellPath );
if ( rimWellPath && rimWellPath->wellPathGeometry() )
{
double totalLength = 0.0;
double weightedConductivity = 0.0;
double weightedWidth = 0.0;
double weightedBetaFactorOnFile = 0.0;
{
std::vector<double> widthResultValues;
{
auto nameUnit = widthParameterNameAndUnit();
widthResultValues = fractureGridResultsForUnitSystem( nameUnit.first,
nameUnit.second,
m_activeTimeStepIndex,
fractureTemplateUnit() );
}
std::vector<double> conductivityResultValues;
{
auto nameUnit = conductivityParameterNameAndUnit();
conductivityResultValues = fractureGridResultsForUnitSystem( nameUnit.first,
nameUnit.second,
m_activeTimeStepIndex,
fractureTemplateUnit() );
}
std::vector<double> betaFactorResultValues;
{
auto nameUnit = betaFactorParameterNameAndUnit();
betaFactorResultValues = fractureGridResults( nameUnit.first, nameUnit.second, m_activeTimeStepIndex );
}
RiaWeightedMeanCalculator<double> widthCalc;
RiaWeightedMeanCalculator<double> conductivityCalc;
RiaWeightedGeometricMeanCalculator betaFactorCalc;
RigWellPathStimplanIntersector intersector( rimWellPath->wellPathGeometry(), fractureInstance );
for ( const auto& v : intersector.intersections() )
{
size_t fractureGlobalCellIndex = v.first;
double intersectionLength = v.second.computeLength();
if ( fractureGlobalCellIndex < widthResultValues.size() )
{
widthCalc.addValueAndWeight( widthResultValues[fractureGlobalCellIndex], intersectionLength );
}
if ( fractureGlobalCellIndex < conductivityResultValues.size() )
{
conductivityCalc.addValueAndWeight( conductivityResultValues[fractureGlobalCellIndex],
intersectionLength );
}
if ( fractureGlobalCellIndex < betaFactorResultValues.size() )
{
double nativeBetaFactor = betaFactorResultValues[fractureGlobalCellIndex];
// Guard against zero beta values, as these values will set the geometric mean to zero
// Consider using the conductivity threshold instead of a local beta threshold
const double threshold = 1e-6;
if ( fabs( nativeBetaFactor ) > threshold )
{
betaFactorCalc.addValueAndWeight( nativeBetaFactor, intersectionLength );
}
}
}
if ( conductivityCalc.validAggregatedWeight() )
{
weightedConductivity = conductivityCalc.weightedMean();
}
if ( widthCalc.validAggregatedWeight() )
{
weightedWidth = widthCalc.weightedMean();
totalLength = widthCalc.aggregatedWeight();
}
if ( betaFactorCalc.validAggregatedWeight() )
{
weightedBetaFactorOnFile = betaFactorCalc.weightedMean();
}
}
if ( totalLength > 1e-7 )
{
values.m_width = weightedWidth;
values.m_conductivity = weightedConductivity;
double conversionFactorForBeta = conversionFactorForBetaValues();
double betaFactorForcheimer = weightedBetaFactorOnFile / conversionFactorForBeta;
values.m_betaFactorInForcheimerUnits = betaFactorForcheimer;
}
values.m_permeability = RigTransmissibilityEquations::permeability( weightedConductivity, weightedWidth );
}
}
else
{
std::pair<size_t, size_t> wellCellIJ = fractureGrid->fractureCellAtWellCenter();
size_t wellCellIndex = fractureGrid->getGlobalIndexFromIJ( wellCellIJ.first, wellCellIJ.second );
const RigFractureCell& wellCell = fractureGrid->cellFromIndex( wellCellIndex );
double conductivity = wellCell.getConductivityValue();
values.m_conductivity = conductivity;
{
auto nameUnit = widthParameterNameAndUnit();
if ( !nameUnit.first.isEmpty() )
{
double widthInRequiredUnit = HUGE_VAL;
{
auto resultValues = fractureGridResultsForUnitSystem( nameUnit.first,
nameUnit.second,
m_activeTimeStepIndex,
fractureTemplateUnit() );
if ( wellCellIndex < resultValues.size() )
{
widthInRequiredUnit = resultValues[wellCellIndex];
}
}
if ( widthInRequiredUnit != HUGE_VAL && fabs( widthInRequiredUnit ) > 1e-20 )
{
values.m_width = widthInRequiredUnit;
values.m_permeability = RigTransmissibilityEquations::permeability( conductivity, widthInRequiredUnit );
}
}
}
{
auto nameUnit = betaFactorParameterNameAndUnit();
std::vector<double> betaFactorResultValues =
fractureGridResults( nameUnit.first, nameUnit.second, m_activeTimeStepIndex );
if ( wellCellIndex < betaFactorResultValues.size() )
{
double nativeBetaValue = betaFactorResultValues[wellCellIndex];
double conversionFactorForBeta = conversionFactorForBetaValues();
double betaFactorForcheimer = nativeBetaValue / conversionFactorForBeta;
values.m_betaFactorInForcheimerUnits = betaFactorForcheimer;
}
}
}
return values;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimMeshFractureTemplate::conversionFactorForBetaValues() const
{
auto nameUnit = betaFactorParameterNameAndUnit();
double conversionFactorForBeta = 1.0;
QString trimmedUnit = nameUnit.second.trimmed().toLower();
if ( trimmedUnit == "/m" )
{
conversionFactorForBeta = 1.01325E+08;
}
else if ( trimmedUnit == "/cm" )
{
conversionFactorForBeta = 1.01325E+06;
}
else if ( trimmedUnit == "/ft" )
{
conversionFactorForBeta = 3.088386E+07;
}
return conversionFactorForBeta;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimMeshFractureTemplate::mapUiResultNameToFileResultName( const QString& uiResultName ) const
{
QString fileResultName;
if ( uiResultName == RiaDefines::conductivityResultName() )
{
fileResultName = m_conductivityResultNameOnFile();
}
else
{
fileResultName = uiResultName;
}
return fileResultName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMeshFractureTemplate::onLoadDataAndUpdateGeometryHasChanged()
{
loadDataAndUpdate();
RimProject::current()->scheduleCreateDisplayModelAndRedrawAllViews();
RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimMeshFractureTemplate::widthResultValues() const
{
std::vector<double> resultValues;
auto nameUnit = widthParameterNameAndUnit();
if ( !nameUnit.first.isEmpty() )
{
resultValues = fractureGridResultsForUnitSystem( nameUnit.first,
nameUnit.second,
m_activeTimeStepIndex,
fractureTemplateUnit() );
}
return resultValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMeshFractureTemplate::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_name );
uiOrdering.add( &m_id );
{
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Input" );
group->add( &m_stimPlanFileName );
group->add( &m_activeTimeStepIndex );
group->add( &m_userDefinedWellPathDepthAtFracture );
group->add( &m_wellPathDepthAtFracture );
m_wellPathDepthAtFracture.uiCapability()->setUiReadOnly( !m_userDefinedWellPathDepthAtFracture() );
}
{
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Geometry" );
group->add( &m_orientationType );
group->add( &m_azimuthAngle );
}
{
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Fracture Truncation" );
group->setCollapsedByDefault( true );
m_fractureContainment()->uiOrdering( uiConfigName, *group );
}
{
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Properties" );
group->add( &m_conductivityResultNameOnFile );
group->add( &m_conductivityType );
group->add( &m_skinFactor );
group->add( &m_perforationLength );
group->add( &m_perforationEfficiency );
group->add( &m_wellDiameter );
}
if ( widthResultValues().empty() )
{
m_fractureWidthType = USER_DEFINED_WIDTH;
}
RimFractureTemplate::defineUiOrdering( uiConfigName, uiOrdering );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMeshFractureTemplate::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
RimFractureTemplate::defineEditorAttribute( field, uiConfigName, attribute );
if ( field == &m_stimPlanFileName )
{
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>( attribute );
if ( myAttr )
{
myAttr->m_fileSelectionFilter = getFileSelectionFilter();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimMeshFractureTemplate::wellPathDepthAtFractureUiName() const
{
return "Well/Fracture Intersection Depth";
}

View File

@ -0,0 +1,108 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimFractureTemplate.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmFieldHandle.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include <vector>
//==================================================================================================
///
///
//==================================================================================================
class RimMeshFractureTemplate : public RimFractureTemplate
{
CAF_PDM_HEADER_INIT;
public:
RimMeshFractureTemplate();
~RimMeshFractureTemplate() override;
int activeTimeStepIndex();
virtual void setDefaultsBasedOnFile() = 0;
void setFileName( const QString& fileName );
QString fileName();
QString wellPathDepthAtFractureUiName() const override;
// Result Access
virtual std::vector<double> timeSteps() = 0;
virtual QStringList conductivityResultNames() const = 0;
virtual std::vector<std::vector<double>>
resultValues( const QString& uiResultName, const QString& unitName, size_t timeStepIndex ) const = 0;
virtual std::vector<double>
fractureGridResults( const QString& resultName, const QString& unitName, size_t timeStepIndex ) const = 0;
virtual bool hasConductivity() const = 0;
virtual double resultValueAtIJ( const RigFractureGrid* fractureGrid,
const QString& uiResultName,
const QString& unitName,
size_t timeStepIndex,
size_t i,
size_t j ) = 0;
virtual QString getFileSelectionFilter() const = 0;
virtual std::vector<double> widthResultValues() const;
QString mapUiResultNameToFileResultName( const QString& uiResultName ) const;
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
void onLoadDataAndUpdateGeometryHasChanged() override;
virtual std::vector<double>
fractureGridResultsForUnitSystem( const QString& resultName,
const QString& unitName,
size_t timeStepIndex,
RiaDefines::EclipseUnitSystem requiredUnitSystem ) const = 0;
WellFractureIntersectionData wellFractureIntersectionData( const RimFracture* fractureInstance ) const override;
virtual std::pair<QString, QString> widthParameterNameAndUnit() const = 0;
virtual std::pair<QString, QString> conductivityParameterNameAndUnit() const = 0;
virtual std::pair<QString, QString> betaFactorParameterNameAndUnit() const = 0;
double conversionFactorForBetaValues() const;
protected:
caf::PdmField<caf::FilePath> m_stimPlanFileName;
bool m_readError;
caf::PdmField<int> m_activeTimeStepIndex;
caf::PdmField<QString> m_conductivityResultNameOnFile;
caf::PdmField<bool> m_userDefinedWellPathDepthAtFracture;
caf::PdmField<QString> m_borderPolygonResultName;
};

View File

@ -63,8 +63,6 @@
#include <cmath>
#include <vector>
static std::vector<double> EMPTY_DOUBLE_VECTOR;
CAF_PDM_SOURCE_INIT( RimStimPlanFractureTemplate, "StimPlanFractureTemplate", "RimStimPlanFractureTemplate" );
//--------------------------------------------------------------------------------------------------
@ -74,23 +72,6 @@ RimStimPlanFractureTemplate::RimStimPlanFractureTemplate()
{
CAF_PDM_InitScriptableObject( "Fracture Template", ":/FractureTemplate16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_stimPlanFileName, "StimPlanFileName", "File Name" );
m_stimPlanFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_userDefinedWellPathDepthAtFracture,
"UserDefinedWellPathDepthAtFracture",
false,
"User-Defined Well/Fracture Intersection Depth" );
CAF_PDM_InitField( &m_borderPolygonResultName, "BorderPolygonResultName", QString( "" ), "Parameter" );
m_borderPolygonResultName.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_activeTimeStepIndex, "ActiveTimeStepIndex", 0, "Active TimeStep Index" );
CAF_PDM_InitField( &m_conductivityResultNameOnFile,
"ConductivityResultName",
QString( "" ),
"Active Conductivity Result Name" );
CAF_PDM_InitFieldNoDefault( &m_propertiesTable, "PropertiesTable", "Properties Table" );
m_propertiesTable.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() );
m_propertiesTable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
@ -116,87 +97,7 @@ RimStimPlanFractureTemplate::~RimStimPlanFractureTemplate()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimStimPlanFractureTemplate::activeTimeStepIndex()
{
return m_activeTimeStepIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStimPlanFractureTemplate::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
RimFractureTemplate::fieldChangedByUi( changedField, oldValue, newValue );
if ( &m_stimPlanFileName == changedField )
{
m_readError = false;
loadDataAndUpdate();
setDefaultsBasedOnXMLfile();
}
if ( &m_userDefinedWellPathDepthAtFracture == changedField )
{
if ( !m_userDefinedWellPathDepthAtFracture )
{
m_readError = false;
loadDataAndUpdate();
RimProject::current()->scheduleCreateDisplayModelAndRedrawAllViews();
}
}
if ( &m_activeTimeStepIndex == changedField )
{
// Changes to this parameters should change all fractures with this fracture template attached.
RimProject* proj = RimProject::current();
for ( RimFracture* fracture : fracturesUsingThisTemplate() )
{
fracture->setStimPlanTimeIndexToPlot( m_activeTimeStepIndex );
}
proj->scheduleCreateDisplayModelAndRedrawAllViews();
}
if ( &m_borderPolygonResultName == changedField || &m_activeTimeStepIndex == changedField ||
&m_stimPlanFileName == changedField || &m_conductivityResultNameOnFile == changedField )
{
// Update fracture grid for all fractures using this template
RimProject* proj = RimProject::current();
for ( RimFracture* fracture : fracturesUsingThisTemplate() )
{
fracture->updateFractureGrid();
}
proj->scheduleCreateDisplayModelAndRedrawAllViews();
}
if ( changedField == &m_scaleApplyButton )
{
m_scaleApplyButton = false;
onLoadDataAndUpdateGeometryHasChanged();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStimPlanFractureTemplate::setFileName( const QString& fileName )
{
m_stimPlanFileName = fileName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimStimPlanFractureTemplate::fileName()
{
return m_stimPlanFileName().path();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStimPlanFractureTemplate::setDefaultsBasedOnXMLfile()
void RimStimPlanFractureTemplate::setDefaultsBasedOnFile()
{
if ( m_stimPlanFractureDefinitionData.isNull() ) return;
@ -324,65 +225,9 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RimStimPlanFractureTemplate::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
QStringList RimStimPlanFractureTemplate::conductivityResultNames() const
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_fractureWidthType )
{
options.push_back(
caf::PdmOptionItemInfo( caf::AppEnum<WidthEnum>::uiText( USER_DEFINED_WIDTH ), USER_DEFINED_WIDTH ) );
if ( !widthResultValues().empty() )
{
options.push_back(
caf::PdmOptionItemInfo( caf::AppEnum<WidthEnum>::uiText( WIDTH_FROM_FRACTURE ), WIDTH_FROM_FRACTURE ) );
}
}
if ( fieldNeedingOptions == &m_betaFactorType )
{
options.push_back( caf::PdmOptionItemInfo( caf::AppEnum<BetaFactorEnum>::uiText( USER_DEFINED_BETA_FACTOR ),
USER_DEFINED_BETA_FACTOR ) );
if ( isBetaFactorAvailableOnFile() )
{
options.push_back( caf::PdmOptionItemInfo( caf::AppEnum<BetaFactorEnum>::uiText( BETA_FACTOR_FROM_FRACTURE ),
BETA_FACTOR_FROM_FRACTURE ) );
}
}
if ( fieldNeedingOptions == &m_borderPolygonResultName )
{
for ( std::pair<QString, QString> nameUnit : uiResultNamesWithUnit() )
{
options.push_back( caf::PdmOptionItemInfo( nameUnit.first, nameUnit.first ) );
}
}
else if ( fieldNeedingOptions == &m_activeTimeStepIndex )
{
std::vector<double> timeValues = timeSteps();
int index = 0;
for ( double value : timeValues )
{
options.push_back( caf::PdmOptionItemInfo( QString::number( value ), index ) );
index++;
}
}
else if ( fieldNeedingOptions == &m_conductivityResultNameOnFile )
{
if ( m_stimPlanFractureDefinitionData.notNull() )
{
QStringList conductivityResultNames = m_stimPlanFractureDefinitionData->conductivityResultNames();
for ( const auto& resultName : conductivityResultNames )
{
options.push_back( caf::PdmOptionItemInfo( resultName, resultName ) );
}
}
}
return options;
return m_stimPlanFractureDefinitionData->conductivityResultNames();
}
//--------------------------------------------------------------------------------------------------
@ -465,175 +310,6 @@ std::vector<double>
return resultValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
WellFractureIntersectionData
RimStimPlanFractureTemplate::wellFractureIntersectionData( const RimFracture* fractureInstance ) const
{
if ( !fractureInstance || !fractureInstance->fractureGrid() ) return {};
WellFractureIntersectionData values;
const RigFractureGrid* fractureGrid = fractureInstance->fractureGrid();
if ( orientationType() == ALONG_WELL_PATH )
{
RimWellPath* rimWellPath = nullptr;
fractureInstance->firstAncestorOrThisOfType( rimWellPath );
if ( rimWellPath && rimWellPath->wellPathGeometry() )
{
double totalLength = 0.0;
double weightedConductivity = 0.0;
double weightedWidth = 0.0;
double weightedBetaFactorOnFile = 0.0;
{
std::vector<double> widthResultValues;
{
auto nameUnit = widthParameterNameAndUnit();
widthResultValues = fractureGridResultsForUnitSystem( nameUnit.first,
nameUnit.second,
m_activeTimeStepIndex,
fractureTemplateUnit() );
}
std::vector<double> conductivityResultValues;
{
auto nameUnit = conductivityParameterNameAndUnit();
conductivityResultValues = fractureGridResultsForUnitSystem( nameUnit.first,
nameUnit.second,
m_activeTimeStepIndex,
fractureTemplateUnit() );
}
std::vector<double> betaFactorResultValues;
{
auto nameUnit = betaFactorParameterNameAndUnit();
betaFactorResultValues = m_stimPlanFractureDefinitionData->fractureGridResults( nameUnit.first,
nameUnit.second,
m_activeTimeStepIndex );
}
RiaWeightedMeanCalculator<double> widthCalc;
RiaWeightedMeanCalculator<double> conductivityCalc;
RiaWeightedGeometricMeanCalculator betaFactorCalc;
RigWellPathStimplanIntersector intersector( rimWellPath->wellPathGeometry(), fractureInstance );
for ( const auto& v : intersector.intersections() )
{
size_t fractureGlobalCellIndex = v.first;
double intersectionLength = v.second.computeLength();
if ( fractureGlobalCellIndex < widthResultValues.size() )
{
widthCalc.addValueAndWeight( widthResultValues[fractureGlobalCellIndex], intersectionLength );
}
if ( fractureGlobalCellIndex < conductivityResultValues.size() )
{
conductivityCalc.addValueAndWeight( conductivityResultValues[fractureGlobalCellIndex],
intersectionLength );
}
if ( fractureGlobalCellIndex < betaFactorResultValues.size() )
{
double nativeBetaFactor = betaFactorResultValues[fractureGlobalCellIndex];
// Guard against zero beta values, as these values will set the geometric mean to zero
// Consider using the conductivity threshold instead of a local beta threshold
const double threshold = 1e-6;
if ( fabs( nativeBetaFactor ) > threshold )
{
betaFactorCalc.addValueAndWeight( nativeBetaFactor, intersectionLength );
}
}
}
if ( conductivityCalc.validAggregatedWeight() )
{
weightedConductivity = conductivityCalc.weightedMean();
}
if ( widthCalc.validAggregatedWeight() )
{
weightedWidth = widthCalc.weightedMean();
totalLength = widthCalc.aggregatedWeight();
}
if ( betaFactorCalc.validAggregatedWeight() )
{
weightedBetaFactorOnFile = betaFactorCalc.weightedMean();
}
}
if ( totalLength > 1e-7 )
{
values.m_width = weightedWidth;
values.m_conductivity = weightedConductivity;
double conversionFactorForBeta = conversionFactorForBetaValues();
double betaFactorForcheimer = weightedBetaFactorOnFile / conversionFactorForBeta;
values.m_betaFactorInForcheimerUnits = betaFactorForcheimer;
}
values.m_permeability = RigTransmissibilityEquations::permeability( weightedConductivity, weightedWidth );
}
}
else
{
std::pair<size_t, size_t> wellCellIJ = fractureGrid->fractureCellAtWellCenter();
size_t wellCellIndex = fractureGrid->getGlobalIndexFromIJ( wellCellIJ.first, wellCellIJ.second );
const RigFractureCell& wellCell = fractureGrid->cellFromIndex( wellCellIndex );
double conductivity = wellCell.getConductivityValue();
values.m_conductivity = conductivity;
{
auto nameUnit = widthParameterNameAndUnit();
if ( !nameUnit.first.isEmpty() )
{
double widthInRequiredUnit = HUGE_VAL;
{
auto resultValues = fractureGridResultsForUnitSystem( nameUnit.first,
nameUnit.second,
m_activeTimeStepIndex,
fractureTemplateUnit() );
if ( wellCellIndex < resultValues.size() )
{
widthInRequiredUnit = resultValues[wellCellIndex];
}
}
if ( widthInRequiredUnit != HUGE_VAL && fabs( widthInRequiredUnit ) > 1e-20 )
{
values.m_width = widthInRequiredUnit;
values.m_permeability = RigTransmissibilityEquations::permeability( conductivity, widthInRequiredUnit );
}
}
}
{
auto nameUnit = betaFactorParameterNameAndUnit();
std::vector<double> betaFactorResultValues =
m_stimPlanFractureDefinitionData->fractureGridResults( nameUnit.first,
nameUnit.second,
m_activeTimeStepIndex );
if ( wellCellIndex < betaFactorResultValues.size() )
{
double nativeBetaValue = betaFactorResultValues[wellCellIndex];
double conversionFactorForBeta = conversionFactorForBetaValues();
double betaFactorForcheimer = nativeBetaValue / conversionFactorForBeta;
values.m_betaFactorInForcheimerUnits = betaFactorForcheimer;
}
}
}
return values;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -829,17 +505,6 @@ void RimStimPlanFractureTemplate::convertToUnitSystem( RiaDefines::EclipseUnitSy
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStimPlanFractureTemplate::onLoadDataAndUpdateGeometryHasChanged()
{
loadDataAndUpdate();
RimProject::current()->scheduleCreateDisplayModelAndRedrawAllViews();
RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -964,25 +629,6 @@ double RimStimPlanFractureTemplate::resultValueAtIJ( const RigFractureGrid* frac
return values[adjustedJ][adjustedI];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimStimPlanFractureTemplate::widthResultValues() const
{
std::vector<double> resultValues;
auto nameUnit = widthParameterNameAndUnit();
if ( !nameUnit.first.isEmpty() )
{
resultValues = fractureGridResultsForUnitSystem( nameUnit.first,
nameUnit.second,
m_activeTimeStepIndex,
fractureTemplateUnit() );
}
return resultValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1025,49 +671,22 @@ void RimStimPlanFractureTemplate::fractureTriangleGeometry( std::vector<cvf::Vec
//--------------------------------------------------------------------------------------------------
void RimStimPlanFractureTemplate::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_name );
uiOrdering.add( &m_id );
{
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Input" );
group->add( &m_stimPlanFileName );
group->add( &m_activeTimeStepIndex );
group->add( &m_userDefinedWellPathDepthAtFracture );
group->add( &m_wellPathDepthAtFracture );
m_wellPathDepthAtFracture.uiCapability()->setUiReadOnly( !m_userDefinedWellPathDepthAtFracture() );
}
{
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Geometry" );
group->add( &m_orientationType );
group->add( &m_azimuthAngle );
}
{
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Fracture Truncation" );
group->setCollapsedByDefault( true );
m_fractureContainment()->uiOrdering( uiConfigName, *group );
}
{
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Properties" );
group->add( &m_conductivityResultNameOnFile );
group->add( &m_conductivityType );
group->add( &m_skinFactor );
group->add( &m_perforationLength );
group->add( &m_perforationEfficiency );
group->add( &m_wellDiameter );
}
RimMeshFractureTemplate::defineUiOrdering( uiConfigName, uiOrdering );
uiOrdering.add( &m_propertiesTable );
if ( widthResultValues().empty() )
{
m_fractureWidthType = USER_DEFINED_WIDTH;
}
// if ( widthResultValues().empty() )
// {
// m_fractureWidthType = USER_DEFINED_WIDTH;
// }
}
RimFractureTemplate::defineUiOrdering( uiConfigName, uiOrdering );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimStimPlanFractureTemplate::getFileSelectionFilter() const
{
return "StimPlan Xml Files(*.xml);;All Files (*.*)";
}
//--------------------------------------------------------------------------------------------------
@ -1077,16 +696,7 @@ void RimStimPlanFractureTemplate::defineEditorAttribute( const caf::PdmFieldHand
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
RimFractureTemplate::defineEditorAttribute( field, uiConfigName, attribute );
if ( field == &m_stimPlanFileName )
{
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>( attribute );
if ( myAttr )
{
myAttr->m_fileSelectionFilter = "StimPlan Xml Files(*.xml);;All Files (*.*)";
}
}
RimMeshFractureTemplate::defineEditorAttribute( field, uiConfigName, attribute );
if ( field == &m_propertiesTable )
{

View File

@ -7,8 +7,8 @@
// 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
// 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>
@ -17,7 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimFractureTemplate.h"
#include "RimMeshFractureTemplate.h"
#include "cafAppEnum.h"
#include "cafPdmChildArrayField.h"
@ -45,7 +45,7 @@ class RigFractureGrid;
///
///
//==================================================================================================
class RimStimPlanFractureTemplate : public RimFractureTemplate
class RimStimPlanFractureTemplate : public RimMeshFractureTemplate
{
CAF_PDM_HEADER_INIT;
@ -53,13 +53,8 @@ public:
RimStimPlanFractureTemplate();
~RimStimPlanFractureTemplate() override;
int activeTimeStepIndex();
void loadDataAndUpdate() override;
void setDefaultsBasedOnXMLfile();
void setFileName( const QString& fileName );
QString fileName();
void setDefaultsBasedOnFile() override;
std::pair<double, double> wellPathDepthAtFractureRange() const override;
QString wellPathDepthAtFractureUiName() const override;
@ -73,61 +68,39 @@ public:
// Result Access
std::vector<double> timeSteps();
std::vector<double> timeSteps() override;
std::vector<std::pair<QString, QString>> uiResultNamesWithUnit() const override;
std::vector<std::vector<double>>
resultValues( const QString& uiResultName, const QString& unitName, size_t timeStepIndex ) const;
std::vector<double> fractureGridResults( const QString& resultName, const QString& unitName, size_t timeStepIndex ) const;
bool hasConductivity() const;
double resultValueAtIJ( const RigFractureGrid* fractureGrid,
const QString& uiResultName,
const QString& unitName,
size_t timeStepIndex,
size_t i,
size_t j );
std::vector<double> widthResultValues() const;
resultValues( const QString& uiResultName, const QString& unitName, size_t timeStepIndex ) const override;
std::vector<double>
fractureGridResults( const QString& resultName, const QString& unitName, size_t timeStepIndex ) const override;
bool hasConductivity() const override;
double resultValueAtIJ( const RigFractureGrid* fractureGrid,
const QString& uiResultName,
const QString& unitName,
size_t timeStepIndex,
size_t i,
size_t j ) override;
void appendDataToResultStatistics( const QString& uiResultName,
const QString& unit,
MinMaxAccumulator& minMaxAccumulator,
PosNegAccumulator& posNegAccumulator ) const override;
QString mapUiResultNameToFileResultName( const QString& uiResultName ) const;
void convertToUnitSystem( RiaDefines::EclipseUnitSystem neededUnit ) override;
double formationDip() const;
static std::pair<QString, QString> widthParameterNameAndUnit( cvf::ref<RigStimPlanFractureDefinition> def );
protected:
void initAfterRead() override;
private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
void onLoadDataAndUpdateGeometryHasChanged() override;
void setDefaultConductivityResultIfEmpty();
bool setBorderPolygonResultNameToDefault();
void computeDepthOfWellPathAtFracture();
void computePerforationLength();
std::vector<double> fractureGridResultsForUnitSystem( const QString& resultName,
const QString& unitName,
size_t timeStepIndex,
RiaDefines::EclipseUnitSystem requiredUnitSystem ) const;
RiaDefines::EclipseUnitSystem requiredUnitSystem ) const override;
WellFractureIntersectionData wellFractureIntersectionData( const RimFracture* fractureInstance ) const override;
std::pair<QString, QString> widthParameterNameAndUnit() const;
std::pair<QString, QString> conductivityParameterNameAndUnit() const;
std::pair<QString, QString> betaFactorParameterNameAndUnit() const;
std::pair<QString, QString> widthParameterNameAndUnit() const override;
std::pair<QString, QString> conductivityParameterNameAndUnit() const override;
std::pair<QString, QString> betaFactorParameterNameAndUnit() const override;
bool isBetaFactorAvailableOnFile() const override;
double conversionFactorForBetaValues() const;
@ -138,16 +111,26 @@ private:
double value,
RigEnsembleFractureStatisticsCalculator::PropertyType propertyType );
QString mapUiResultNameToFileResultName( const QString& uiResultName ) const;
void convertToUnitSystem( RiaDefines::EclipseUnitSystem neededUnit ) override;
double formationDip() const;
static std::pair<QString, QString> widthParameterNameAndUnit( cvf::ref<RigStimPlanFractureDefinition> def );
protected:
void initAfterRead() override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
QString getFileSelectionFilter() const override;
QStringList conductivityResultNames() const override;
private:
caf::PdmField<int> m_activeTimeStepIndex;
caf::PdmField<QString> m_conductivityResultNameOnFile;
caf::PdmField<bool> m_userDefinedWellPathDepthAtFracture;
caf::PdmField<QString> m_borderPolygonResultName;
caf::PdmField<caf::FilePath> m_stimPlanFileName;
cvf::ref<RigStimPlanFractureDefinition> m_stimPlanFractureDefinitionData;
bool m_readError;
caf::PdmField<QString> m_propertiesTable;