///////////////////////////////////////////////////////////////////////////////// // // 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 "RimFractureModel.h" #include "RicElasticPropertiesImportTools.h" #include "cafPdmUiLineEditor.h" #include "cafPdmUiTextEditor.h" CAF_PDM_SOURCE_INIT( RimElasticProperties, "ElasticProperties" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimElasticProperties::RimElasticProperties() { CAF_PDM_InitObject( "RimElasticProperties", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path", "", "", "" ); m_filePath.uiCapability()->setUiReadOnly( true ); m_filePath.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); CAF_PDM_InitFieldNoDefault( &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(); 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::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( "" " " " " " " " " " " " " " " " " " " " " " " " " " " ); QString body; for ( auto prop : m_properties ) { const QString& fieldName = prop.second.fieldName(); const std::vector& porosity = prop.second.porosity(); const std::vector& youngsModulus = prop.second.youngsModulus(); const std::vector& poissonsRatio = prop.second.poissonsRatio(); const std::vector& K_Ic = prop.second.K_Ic(); const std::vector& proppantEmbedment = prop.second.proppantEmbedment(); for ( size_t i = 0; i < porosity.size(); i++ ) { QString format( "" " " " " " " " " " " " " " " " " "" ); QString line = format.arg( fieldName ) .arg( prop.second.formationName() ) .arg( prop.second.faciesName() ) .arg( porosity[i] ) .arg( youngsModulus[i] ) .arg( poissonsRatio[i] ) .arg( K_Ic[i] ) .arg( proppantEmbedment[i] ); body.append( line ); } } QString footer( "
FieldFormationFaciesPorosityYoung's
Modulus
Poisson's
Ratio
K-IcProppant
Embedment
%1%2%3%4%5%6%7%8
" ); return header + body + footer; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimElasticProperties::loadDataAndUpdate() { if ( !m_filePath().path().isEmpty() ) { RimFractureModel* fractureModel; firstAncestorOrThisOfType( fractureModel ); RicElasticPropertiesImportTools::importElasticPropertiesFromFile( m_filePath().path(), fractureModel ); } }