///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2020- 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 // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RimElasticProperties.h" #include "RimElasticPropertyScalingCollection.h" #include "RimStimPlanModelTemplate.h" #include "RicElasticPropertiesImportTools.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" #include "cafPdmUiLineEditor.h" #include "cafPdmUiTextEditor.h" CAF_PDM_SOURCE_INIT( RimElasticProperties, "ElasticProperties" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimElasticProperties::RimElasticProperties() : changed( this ) { CAF_PDM_InitScriptableObject( "RimElasticProperties" ); CAF_PDM_InitScriptableFieldNoDefault( &m_filePath, "FilePath", "File Path" ); m_filePath.uiCapability()->setUiReadOnly( true ); m_filePath.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); CAF_PDM_InitScriptableFieldNoDefault( &m_propertiesTable, "PropertiesTable", "Properties Table" ); m_propertiesTable.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); m_propertiesTable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_propertiesTable.uiCapability()->setUiReadOnly( true ); m_propertiesTable.xmlCapability()->disableIO(); CAF_PDM_InitScriptableField( &m_showScaledProperties, "ShowScaledProperties", true, "Show Scaled Properties" ); CAF_PDM_InitScriptableFieldNoDefault( &m_scalings, "PropertyScalingCollection", "PropertyScalingCollection" ); m_scalings.uiCapability()->setUiTreeHidden( true ); m_scalings = new RimElasticPropertyScalingCollection; m_scalings->changed.connect( this, &RimElasticProperties::elasticPropertyScalingCollectionChanged ); setUiName( "Elastic Properties" ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimElasticProperties::~RimElasticProperties() { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QString RimElasticProperties::filePath() const { return m_filePath.v().path(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimElasticProperties::setFilePath( const QString& filePath ) { m_filePath = filePath; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimElasticProperties::setPropertiesForFacies( FaciesKey& key, const RigElasticProperties& properties ) { m_properties.insert( std::pair( key, properties ) ); m_propertiesTable = generatePropertiesTable(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RimElasticProperties::hasPropertiesForFacies( FaciesKey& key ) const { return m_properties.find( key ) != m_properties.end(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- const RigElasticProperties& RimElasticProperties::propertiesForFacies( FaciesKey& key ) const { assert( hasPropertiesForFacies( key ) ); return m_properties.find( key )->second; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimElasticProperties::clearProperties() { m_properties.clear(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimElasticProperties::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { if ( changedField == &m_showScaledProperties ) { m_propertiesTable = generatePropertiesTable(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimElasticProperties::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { uiOrdering.add( &m_filePath ); uiOrdering.add( &m_showScaledProperties ); uiOrdering.add( &m_propertiesTable ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimElasticProperties::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) { if ( field == &m_propertiesTable ) { auto myAttr = dynamic_cast( attribute ); if ( myAttr ) { myAttr->wrapMode = caf::PdmUiTextEditorAttribute::NoWrap; myAttr->textMode = caf::PdmUiTextEditorAttribute::HTML; } } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QString RimElasticProperties::generatePropertiesTable() { QString header( "" " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " ); std::vector properties = scalableProperties(); QString body; for ( auto prop : m_properties ) { const QString& fieldName = prop.second.fieldName(); const QString& formationName = prop.second.formationName(); const QString& faciesName = prop.second.faciesName(); const std::vector& porosity = prop.second.porosity(); for ( size_t i = 0; i < porosity.size(); i++ ) { QString line = QString( "" " " " " " " " " ) .arg( fieldName ) .arg( formationName ) .arg( faciesName ) .arg( porosity[i] ); for ( auto property : properties ) { double scale = 1.0; if ( m_showScaledProperties() ) { scale = getPropertyScaling( formationName, faciesName, property ); } double value = prop.second.getValue( property, i, scale ); QString propertyElement = QString( "" ).arg( value ); line.append( propertyElement ); } line.append( "" ); body.append( line ); } } QString footer( "
FieldFormationFaciesPorosityYoung's
Modulus
Poisson's
Ratio
K-IcProppant
Embedment
Biot
Coefficient
k0Fluid Loss
Coefficient
Spurt LossImmobile Fluid
Saturation
%1%2%3%4%1
" ); return header + body + footer; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimElasticProperties::loadDataAndUpdate() { if ( !m_filePath().path().isEmpty() ) { RimStimPlanModelTemplate* stimPlanModelTemplate; firstAncestorOrThisOfType( stimPlanModelTemplate ); RicElasticPropertiesImportTools::importElasticPropertiesFromFile( m_filePath().path(), stimPlanModelTemplate ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimElasticPropertyScalingCollection* RimElasticProperties::scalingCollection() { return m_scalings.value(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::vector RimElasticProperties::scalableProperties() { std::vector properties = { RiaDefines::CurveProperty::YOUNGS_MODULUS, RiaDefines::CurveProperty::POISSONS_RATIO, RiaDefines::CurveProperty::K_IC, RiaDefines::CurveProperty::PROPPANT_EMBEDMENT, RiaDefines::CurveProperty::BIOT_COEFFICIENT, RiaDefines::CurveProperty::K0, RiaDefines::CurveProperty::FLUID_LOSS_COEFFICIENT, RiaDefines::CurveProperty::SPURT_LOSS, RiaDefines::CurveProperty::IMMOBILE_FLUID_SATURATION, }; return properties; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RimElasticProperties::isScalableProperty( RiaDefines::CurveProperty property ) { std::vector properties = scalableProperties(); return std::find( properties.begin(), properties.end(), property ) != properties.end(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- double RimElasticProperties::getPropertyScaling( const QString& formationName, const QString& faciesName, RiaDefines::CurveProperty property ) const { if ( m_scalings ) { return m_scalings->getScaling( formationName, faciesName, property ); } return 1.0; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimElasticProperties::elasticPropertyScalingCollectionChanged( const caf::SignalEmitter* emitter ) { m_propertiesTable = generatePropertiesTable(); changed.send(); }