2015-06-19 14:09:45 +02:00
/////////////////////////////////////////////////////////////////////////////////
//
2019-02-15 09:37:17 +01:00
// Copyright (C) 2018- Equinor ASA
// Copyright (C) 2015-2018 Statoil ASA
2015-06-19 14:09:45 +02:00
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "RimGeoMechResultDefinition.h"
2015-08-27 14:57:04 +02:00
2015-06-19 14:09:45 +02:00
#include "RifGeoMechReaderInterface.h"
2015-08-27 14:57:04 +02:00
2015-06-19 14:09:45 +02:00
#include "RigFemPartResultsCollection.h"
#include "RigFemResultAddress.h"
2015-08-27 14:57:04 +02:00
#include "RigGeoMechCaseData.h"
2018-02-15 10:58:13 +01:00
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
2015-08-27 14:57:04 +02:00
2017-06-13 15:41:52 +02:00
#include "RiaDefines.h"
2018-05-03 10:08:24 +02:00
#include "Rim3dWellLogCurve.h"
2015-08-27 14:57:04 +02:00
#include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h"
#include "RimGeoMechPropertyFilter.h"
#include "RimGeoMechView.h"
2018-02-01 17:45:22 +01:00
#include "RimIntersectionCollection.h"
2017-03-21 13:17:02 +01:00
#include "RimPlotCurve.h"
2015-09-07 14:29:46 +02:00
#include "RimViewLinker.h"
2015-08-27 14:57:04 +02:00
#include "cafPdmUiListEditor.h"
2015-06-19 14:09:45 +02:00
namespace caf {
template <>
void caf :: AppEnum < RigFemResultPosEnum >:: setUp ()
{
addItem ( RIG_NODAL , "NODAL" , "Nodal" );
addItem ( RIG_ELEMENT_NODAL , "ELEMENT_NODAL" , "Element Nodal" );
addItem ( RIG_INTEGRATION_POINT , "INTEGRATION_POINT" , "Integration Point" );
2016-10-19 12:22:13 +02:00
addItem ( RIG_ELEMENT_NODAL_FACE , "ELEMENT_NODAL_FACE" , "Element Nodal On Face" );
2016-09-06 10:27:30 +02:00
addItem ( RIG_FORMATION_NAMES , "FORMATION_NAMES" , "Formation Names" );
2018-01-08 16:07:23 +01:00
addItem ( RIG_ELEMENT , "ELEMENT" , "Element" );
2018-06-05 11:56:47 +02:00
addItem ( RIG_WELLPATH_DERIVED , "WELLPATH_DERIVED" , "Well Path Derived" );
2015-06-19 14:09:45 +02:00
setDefault ( RIG_NODAL );
}
}
CAF_PDM_SOURCE_INIT ( RimGeoMechResultDefinition , "GeoMechResultDefinition" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechResultDefinition :: RimGeoMechResultDefinition ( void )
{
CAF_PDM_InitObject ( "Color Result" , ":/CellResult.png" , "" , "" );
CAF_PDM_InitFieldNoDefault ( & m_resultPositionType , "ResultPositionType" , "Result Position" , "" , "" , "" );
2015-08-05 13:27:36 +02:00
m_resultPositionType . uiCapability () -> setUiHidden ( true );
2016-10-10 16:09:54 +02:00
2015-06-19 14:09:45 +02:00
CAF_PDM_InitField ( & m_resultFieldName , "ResultFieldName" , QString ( "" ), "Field Name" , "" , "" , "" );
2015-08-05 13:27:36 +02:00
m_resultFieldName . uiCapability () -> setUiHidden ( true );
2016-10-10 16:09:54 +02:00
2015-06-19 14:09:45 +02:00
CAF_PDM_InitField ( & m_resultComponentName , "ResultComponentName" , QString ( "" ), "Component" , "" , "" , "" );
2015-08-05 13:27:36 +02:00
m_resultComponentName . uiCapability () -> setUiHidden ( true );
2015-06-19 14:09:45 +02:00
2019-02-15 09:37:17 +01:00
CAF_PDM_InitField ( & m_timeLapseBaseTimestep , "TimeLapseBaseTimeStep" , ( int ) RigFemResultAddress :: NO_TIME_LAPSE , "Base Time Step" , "" , "" , "" );
2016-10-10 16:09:54 +02:00
2018-02-15 10:58:13 +01:00
CAF_PDM_InitField ( & m_compactionRefLayer , "CompactionRefLayer" , 0 , "Compaction Ref Layer" , "" , "" , "" );
m_compactionRefLayer . uiCapability () -> setUiHidden ( true );
2015-06-19 14:09:45 +02:00
CAF_PDM_InitFieldNoDefault ( & m_resultPositionTypeUiField , "ResultPositionTypeUi" , "Result Position" , "" , "" , "" );
2018-11-05 14:27:34 +01:00
m_resultPositionTypeUiField . xmlCapability () -> disableIO ();
2015-06-19 14:09:45 +02:00
CAF_PDM_InitField ( & m_resultVariableUiField , "ResultVariableUI" , QString ( "" ), "Value" , "" , "" , "" );
2018-11-05 14:27:34 +01:00
m_resultVariableUiField . xmlCapability () -> disableIO ();
2015-06-19 14:09:45 +02:00
2015-08-05 13:27:36 +02:00
m_resultVariableUiField . uiCapability () -> setUiEditorTypeName ( caf :: PdmUiListEditor :: uiEditorTypeName ());
m_resultVariableUiField . uiCapability () -> setUiLabelPosition ( caf :: PdmUiItemInfo :: TOP );
2016-10-10 16:09:54 +02:00
2018-03-06 13:10:58 +01:00
CAF_PDM_InitField ( & m_compactionRefLayerUiField , "CompactionRefLayerUi" , ( int ) RigFemResultAddress :: NO_COMPACTION , "Compaction Ref Layer" , "" , "The compaction is calculated with reference to this layer. Default layer is the topmost layer with POR" , "" );
2018-11-05 14:27:34 +01:00
m_compactionRefLayerUiField . xmlCapability () -> disableIO ();
2018-02-15 10:58:13 +01:00
2019-02-15 09:37:17 +01:00
// OBSOLETE FIELDS
CAF_PDM_InitField ( & m_isTimeLapseResult_OBSOLETE , "IsTimeLapseResult" , true , "TimeLapseResult" , "" , "" , "" );
m_isTimeLapseResult_OBSOLETE . xmlCapability () -> setIOWritable ( false );
m_isTimeLapseResult_OBSOLETE . uiCapability () -> setUiHidden ( true );
2018-02-13 10:49:26 +01:00
m_isChangedByField = false ;
2018-06-05 11:56:47 +02:00
m_addWellPathDerivedResults = false ;
2015-06-19 14:09:45 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechResultDefinition ::~ RimGeoMechResultDefinition ( void )
{
}
2016-10-10 16:09:54 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechResultDefinition :: defineUiOrdering ( QString uiConfigName , caf :: PdmUiOrdering & uiOrdering )
{
uiOrdering . add ( & m_resultPositionTypeUiField );
uiOrdering . add ( & m_resultVariableUiField );
2019-02-15 09:37:17 +01:00
QString valueLabel = "Value" ;
if ( m_timeLapseBaseTimestep != RigFemResultAddress :: NO_TIME_LAPSE )
{
valueLabel += QString ( " (%1)" ). arg ( diffResultUiName ());
}
m_resultVariableUiField . uiCapability () -> setUiName ( valueLabel );
2017-04-20 15:27:41 +02:00
if ( m_resultPositionTypeUiField () != RIG_FORMATION_NAMES )
{
2019-02-15 09:37:17 +01:00
caf :: PdmUiGroup * timeLapseGr = uiOrdering . addNewGroup ( "Difference Options" );
timeLapseGr -> add ( & m_timeLapseBaseTimestep );
2017-04-20 15:27:41 +02:00
}
2016-10-10 17:32:47 +02:00
2018-02-15 10:58:13 +01:00
if ( m_resultPositionTypeUiField () == RIG_NODAL )
{
caf :: PdmUiGroup * compactionGroup = uiOrdering . addNewGroup ( "Compaction Options" );
2018-03-05 14:36:42 +01:00
compactionGroup -> add ( & m_compactionRefLayerUiField );
2018-03-06 09:33:03 +01:00
2018-03-06 13:10:58 +01:00
if ( m_compactionRefLayerUiField == ( int ) RigFemResultAddress :: NO_COMPACTION )
2018-03-06 09:33:03 +01:00
{
2018-04-23 16:35:19 +02:00
if ( m_geomCase && m_geomCase -> geoMechData () )
{
2018-08-31 10:35:33 +02:00
m_compactionRefLayerUiField = ( int ) m_geomCase -> geoMechData () -> femParts () -> part ( 0 ) -> getOrCreateStructGrid () -> reservoirIJKBoundingBox (). first . z ();
2018-04-23 16:35:19 +02:00
}
2018-03-06 09:33:03 +01:00
}
2018-02-15 10:58:13 +01:00
}
2018-02-13 10:49:26 +01:00
if ( ! m_isChangedByField )
{
m_resultPositionTypeUiField = m_resultPositionType ;
m_resultVariableUiField = composeFieldCompString ( m_resultFieldName (), m_resultComponentName ());
}
m_isChangedByField = false ;
2017-03-21 13:47:53 +01:00
uiOrdering . skipRemainingFields ( true );
2016-10-10 16:09:54 +02:00
}
2015-06-19 14:09:45 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList < caf :: PdmOptionItemInfo > RimGeoMechResultDefinition :: calculateValueOptions ( const caf :: PdmFieldHandle * fieldNeedingOptions , bool * useOptionsOnly )
{
QList < caf :: PdmOptionItemInfo > options ;
* useOptionsOnly = true ;
2015-09-01 17:11:23 +02:00
if ( m_geomCase )
2015-06-19 14:09:45 +02:00
{
2018-06-05 11:56:47 +02:00
if ( & m_resultPositionTypeUiField == fieldNeedingOptions )
{
std :: vector < RigFemResultPosEnum > optionItems = { RIG_NODAL , RIG_ELEMENT_NODAL , RIG_INTEGRATION_POINT , RIG_ELEMENT_NODAL_FACE , RIG_FORMATION_NAMES , RIG_ELEMENT };
2018-06-22 08:26:38 +02:00
if ( m_addWellPathDerivedResults )
2018-06-05 11:56:47 +02:00
{
optionItems . push_back ( RIG_WELLPATH_DERIVED );
}
for ( RigFemResultPosEnum value : optionItems )
{
options . push_back ( caf :: PdmOptionItemInfo ( caf :: AppEnum < RigFemResultPosEnum >:: uiText ( value ), QVariant ( value )));
}
}
else if ( & m_resultVariableUiField == fieldNeedingOptions )
2015-06-19 14:09:45 +02:00
{
std :: map < std :: string , std :: vector < std :: string > > fieldCompNames = getResultMetaDataForUIFieldSetting ();
2018-01-15 17:40:39 +01:00
2015-06-19 14:09:45 +02:00
QStringList uiVarNames ;
QStringList varNames ;
2017-04-20 15:27:41 +02:00
2019-02-15 09:37:17 +01:00
getUiAndResultVariableStringList ( & uiVarNames , & varNames , fieldCompNames );
2015-06-19 14:09:45 +02:00
for ( int oIdx = 0 ; oIdx < uiVarNames . size (); ++ oIdx )
{
options . push_back ( caf :: PdmOptionItemInfo ( uiVarNames [ oIdx ], varNames [ oIdx ]));
}
}
2019-02-15 09:37:17 +01:00
else if ( & m_timeLapseBaseTimestep == fieldNeedingOptions )
2016-10-10 16:09:54 +02:00
{
std :: vector < std :: string > stepNames ;
if ( m_geomCase -> geoMechData ())
{
2018-06-11 13:47:21 +02:00
stepNames = m_geomCase -> geoMechData () -> femPartResults () -> filteredStepNames ();
2016-10-10 16:09:54 +02:00
}
2019-02-15 09:37:17 +01:00
options . push_back ( caf :: PdmOptionItemInfo ( QString ( "Disabled" ), ( int ) RigFemResultAddress :: NO_TIME_LAPSE ));
2016-10-10 16:09:54 +02:00
for ( size_t stepIdx = 0 ; stepIdx < stepNames . size (); ++ stepIdx )
{
2019-02-15 09:37:17 +01:00
options . push_back ( caf :: PdmOptionItemInfo ( QString ( "%1 (#%2)" ). arg ( QString :: fromStdString ( stepNames [ stepIdx ])). arg ( stepIdx ), static_cast < int > ( stepIdx )));
2016-10-10 16:09:54 +02:00
}
}
2018-02-15 10:58:13 +01:00
else if ( & m_compactionRefLayerUiField == fieldNeedingOptions )
{
2018-04-23 16:35:19 +02:00
if ( m_geomCase -> geoMechData ())
2018-02-15 10:58:13 +01:00
{
2018-08-31 10:35:33 +02:00
size_t kCount = m_geomCase -> geoMechData () -> femParts () -> part ( 0 ) -> getOrCreateStructGrid () -> gridPointCountK () - 1 ;
2018-04-23 16:35:19 +02:00
for ( size_t layerIdx = 0 ; layerIdx < kCount ; ++ layerIdx )
{
options . push_back ( caf :: PdmOptionItemInfo ( QString :: number ( layerIdx + 1 ), ( int ) layerIdx ));
}
2018-02-15 10:58:13 +01:00
}
}
2015-06-19 14:09:45 +02:00
}
return options ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-09-01 17:11:23 +02:00
void RimGeoMechResultDefinition :: setGeoMechCase ( RimGeoMechCase * geomCase )
2015-06-19 14:09:45 +02:00
{
2015-09-01 17:11:23 +02:00
m_geomCase = geomCase ;
2015-06-19 14:09:45 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechResultDefinition :: fieldChangedByUi ( const caf :: PdmFieldHandle * changedField , const QVariant & oldValue , const QVariant & newValue )
{
2018-02-13 10:49:26 +01:00
m_isChangedByField = true ;
2018-06-08 14:02:17 +02:00
if ( & m_resultPositionTypeUiField == changedField )
{
2019-02-15 09:37:17 +01:00
if ( m_resultPositionTypeUiField () == RIG_WELLPATH_DERIVED || m_resultPositionType () == RIG_FORMATION_NAMES )
2018-06-08 14:02:17 +02:00
{
2019-02-15 09:37:17 +01:00
m_timeLapseBaseTimestep = RigFemResultAddress :: NO_TIME_LAPSE ;
m_timeLapseBaseTimestep . uiCapability () -> setUiReadOnly ( true );
2018-06-08 14:02:17 +02:00
}
else
2019-02-15 09:37:17 +01:00
{
m_timeLapseBaseTimestep . uiCapability () -> setUiReadOnly ( false );
2018-06-11 08:45:27 +02:00
}
}
2016-10-10 16:37:13 +02:00
if ( & m_resultPositionTypeUiField == changedField
2019-02-15 09:37:17 +01:00
|| & m_timeLapseBaseTimestep == changedField )
2015-06-19 14:09:45 +02:00
{
std :: map < std :: string , std :: vector < std :: string > > fieldCompNames = getResultMetaDataForUIFieldSetting ();
QStringList uiVarNames ;
QStringList varNames ;
2019-02-15 09:37:17 +01:00
getUiAndResultVariableStringList ( & uiVarNames , & varNames , fieldCompNames );
2015-06-19 14:09:45 +02:00
if ( m_resultPositionTypeUiField () == m_resultPositionType ()
2015-09-26 09:38:29 +02:00
&& varNames . contains ( composeFieldCompString ( m_resultFieldName (), m_resultComponentName ())))
2015-06-19 14:09:45 +02:00
{
2015-09-26 09:38:29 +02:00
m_resultVariableUiField = composeFieldCompString ( m_resultFieldName (), m_resultComponentName ());
2015-06-19 14:09:45 +02:00
}
else
{
m_resultVariableUiField = "" ;
}
}
2015-08-10 17:26:19 +02:00
// Get the possible property filter owner
RimGeoMechPropertyFilter * propFilter = dynamic_cast < RimGeoMechPropertyFilter *> ( this -> parentField () -> ownerObject ());
2018-02-01 17:45:22 +01:00
RimGridView * view = nullptr ;
2016-09-21 13:59:41 +02:00
this -> firstAncestorOrThisOfType ( view );
2017-03-21 13:17:02 +01:00
RimPlotCurve * curve = nullptr ;
2016-09-21 13:59:41 +02:00
this -> firstAncestorOrThisOfType ( curve );
2018-05-03 10:08:24 +02:00
Rim3dWellLogCurve * rim3dWellLogCurve = nullptr ;
this -> firstAncestorOrThisOfType ( rim3dWellLogCurve );
2015-09-02 09:17:36 +02:00
2019-02-15 09:37:17 +01:00
if ( & m_resultVariableUiField == changedField || & m_compactionRefLayerUiField == changedField || & m_timeLapseBaseTimestep == changedField )
2015-06-19 14:09:45 +02:00
{
QStringList fieldComponentNames = m_resultVariableUiField (). split ( QRegExp ( " \\ s+" ));
if ( fieldComponentNames . size () > 0 )
{
m_resultPositionType = m_resultPositionTypeUiField ;
2016-09-13 13:43:20 +02:00
if ( m_resultPositionType () == RIG_FORMATION_NAMES )
2015-06-19 14:09:45 +02:00
{
2016-09-13 13:43:20 +02:00
// Complete string of selected formation is stored in m_resultFieldName
m_resultFieldName = m_resultVariableUiField ();
m_resultComponentName = "" ;
2015-06-19 14:09:45 +02:00
}
else
{
2016-09-13 13:43:20 +02:00
m_resultFieldName = fieldComponentNames [ 0 ];
if ( fieldComponentNames . size () > 1 )
{
m_resultComponentName = fieldComponentNames [ 1 ];
}
else
{
m_resultComponentName = "" ;
}
2016-10-10 16:09:54 +02:00
2018-02-15 10:58:13 +01:00
m_compactionRefLayer = m_compactionRefLayerUiField ();
2015-06-19 14:09:45 +02:00
}
2018-04-23 16:35:19 +02:00
if ( m_geomCase -> geoMechData () && m_geomCase -> geoMechData () -> femPartResults () -> assertResultsLoaded ( this -> resultAddress ()))
2015-06-19 14:09:45 +02:00
{
2015-09-01 17:11:23 +02:00
if ( view ) view -> hasUserRequestedAnimation = true ;
2015-06-19 14:09:45 +02:00
}
2015-08-10 17:26:19 +02:00
if ( propFilter )
2015-06-19 14:09:45 +02:00
{
2015-08-10 17:26:19 +02:00
propFilter -> setToDefaultValues ();
2015-06-23 11:18:37 +02:00
2015-09-01 17:11:23 +02:00
if ( view ) view -> scheduleGeometryRegen ( PROPERTY_FILTERED );
2015-06-19 14:09:45 +02:00
}
2018-02-01 17:45:22 +01:00
if ( view )
{
view -> scheduleCreateDisplayModelAndRedraw ();
view -> crossSectionCollection () -> scheduleCreateDisplayModelAndRedraw2dIntersectionViews ();
}
2015-08-27 14:57:04 +02:00
if ( dynamic_cast < RimGeoMechCellColors *> ( this ))
{
2016-09-06 14:03:02 +02:00
this -> updateLegendCategorySettings ();
2015-09-01 17:14:22 +02:00
if ( view )
{
2015-09-25 11:01:41 +02:00
RimViewLinker * viewLinker = view -> assosiatedViewLinker ();
2015-09-07 14:29:46 +02:00
if ( viewLinker )
2015-09-01 17:14:22 +02:00
{
2015-09-07 14:29:46 +02:00
viewLinker -> updateCellResult ();
2015-09-01 17:14:22 +02:00
}
}
2015-08-27 14:57:04 +02:00
}
2015-09-02 09:17:36 +02:00
if ( curve )
{
2017-09-23 08:47:04 +02:00
curve -> loadDataAndUpdate ( true );
2015-09-02 09:17:36 +02:00
}
2018-05-03 10:08:24 +02:00
if ( rim3dWellLogCurve )
{
rim3dWellLogCurve -> updateCurveIn3dView ();
}
2015-06-19 14:09:45 +02:00
}
}
2015-08-10 17:26:19 +02:00
if ( propFilter )
2015-06-19 14:09:45 +02:00
{
2015-08-10 17:26:19 +02:00
propFilter -> updateConnectedEditors ();
2015-06-19 14:09:45 +02:00
}
2015-09-02 09:17:36 +02:00
if ( curve )
{
curve -> updateConnectedEditors ();
}
2018-05-03 10:08:24 +02:00
if ( rim3dWellLogCurve )
{
rim3dWellLogCurve -> resetMinMaxValuesAndUpdateUI ();
}
2015-06-19 14:09:45 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std :: map < std :: string , std :: vector < std :: string > > RimGeoMechResultDefinition :: getResultMetaDataForUIFieldSetting ()
{
2015-09-01 17:11:23 +02:00
RimGeoMechCase * gmCase = m_geomCase ;
2016-10-19 12:22:13 +02:00
std :: map < std :: string , std :: vector < std :: string > > fieldWithComponentNames ;
2015-06-19 14:09:45 +02:00
if ( gmCase && gmCase -> geoMechData ())
{
2016-10-19 12:22:13 +02:00
fieldWithComponentNames = gmCase -> geoMechData () -> femPartResults () -> scalarFieldAndComponentNames ( m_resultPositionTypeUiField ());
2015-06-19 14:09:45 +02:00
}
2016-10-19 12:22:13 +02:00
return fieldWithComponentNames ;
2015-06-19 14:09:45 +02:00
}
2015-06-23 11:18:37 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2016-10-10 16:09:54 +02:00
void RimGeoMechResultDefinition :: getUiAndResultVariableStringList ( QStringList * uiNames ,
QStringList * variableNames ,
2019-02-15 09:37:17 +01:00
const std :: map < std :: string , std :: vector < std :: string > >& fieldCompNames )
2015-06-19 14:09:45 +02:00
{
CVF_ASSERT ( uiNames && variableNames );
std :: map < std :: string , std :: vector < std :: string > >:: const_iterator fieldIt ;
for ( fieldIt = fieldCompNames . begin (); fieldIt != fieldCompNames . end (); ++ fieldIt )
{
QString resultFieldName = QString :: fromStdString ( fieldIt -> first );
2015-09-26 09:38:29 +02:00
if ( resultFieldName == "E" || resultFieldName == "S" || resultFieldName == "POR" ) continue ; // We will not show the native POR, Stress and Strain
2015-06-19 14:09:45 +02:00
2019-02-15 09:37:17 +01:00
QString resultFieldUiName = convertToUiResultFieldName ( resultFieldName );
2015-06-19 14:09:45 +02:00
uiNames -> push_back ( resultFieldUiName );
variableNames -> push_back ( resultFieldName );
std :: vector < std :: string >:: const_iterator compIt ;
for ( compIt = fieldIt -> second . begin (); compIt != fieldIt -> second . end (); ++ compIt )
{
QString resultCompName = QString :: fromStdString ( * compIt );
2019-02-21 08:08:27 +01:00
uiNames -> push_back ( " " + resultCompName );
2015-09-26 09:38:29 +02:00
variableNames -> push_back ( composeFieldCompString ( resultFieldName , resultCompName ));
2015-06-19 14:09:45 +02:00
}
}
}
2015-06-23 11:18:37 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-09-26 09:38:29 +02:00
QString RimGeoMechResultDefinition :: composeFieldCompString ( const QString & resultFieldName , const QString & resultComponentName )
2015-06-19 14:09:45 +02:00
{
2015-09-26 09:38:29 +02:00
if ( resultComponentName . isEmpty ())
return resultFieldName ;
else
return resultFieldName + " " + resultComponentName ;
2015-06-19 14:09:45 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechResultDefinition :: initAfterRead ()
{
2019-02-15 09:37:17 +01:00
if ( ! m_isTimeLapseResult_OBSOLETE ())
{
m_timeLapseBaseTimestep = RigFemResultAddress :: NO_TIME_LAPSE ;
}
2015-06-19 14:09:45 +02:00
m_resultPositionTypeUiField = m_resultPositionType ;
2019-02-15 09:37:17 +01:00
m_resultVariableUiField = composeFieldCompString ( m_resultFieldName (), m_resultComponentName ());
2018-02-15 10:58:13 +01:00
m_compactionRefLayerUiField = m_compactionRefLayer ;
2019-02-15 09:37:17 +01:00
m_timeLapseBaseTimestep . uiCapability () -> setUiReadOnly ( resultPositionType () == RIG_WELLPATH_DERIVED );
2015-06-19 14:09:45 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechResultDefinition :: loadResult ()
{
2018-04-23 16:35:19 +02:00
if ( m_geomCase && m_geomCase -> geoMechData ())
2015-06-19 14:09:45 +02:00
{
2018-07-02 09:47:34 +02:00
if ( this -> resultAddress (). fieldName == RiaDefines :: wellPathFGResultName (). toStdString () ||
this -> resultAddress (). fieldName == RiaDefines :: wellPathSFGResultName (). toStdString ())
2018-06-05 11:56:47 +02:00
{
RigFemResultAddress stressResAddr ( RIG_ELEMENT_NODAL , std :: string ( "ST" ), "" );
RigFemResultAddress porBarResAddr ( RIG_ELEMENT_NODAL , std :: string ( "POR-Bar" ), "" );
m_geomCase -> geoMechData () -> femPartResults () -> assertResultsLoaded ( stressResAddr );
m_geomCase -> geoMechData () -> femPartResults () -> assertResultsLoaded ( porBarResAddr );
}
else
{
m_geomCase -> geoMechData () -> femPartResults () -> assertResultsLoaded ( this -> resultAddress ());
}
2015-06-19 14:09:45 +02:00
}
}
2018-06-05 11:56:47 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechResultDefinition :: setAddWellPathDerivedResults ( bool addWellPathDerivedResults )
{
m_addWellPathDerivedResults = addWellPathDerivedResults ;
}
2016-10-10 16:09:54 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-06-18 14:17:13 +02:00
RigFemResultAddress RimGeoMechResultDefinition :: resultAddress () const
2016-10-10 16:09:54 +02:00
{
2018-02-15 10:58:13 +01:00
return RigFemResultAddress ( resultPositionType (),
resultFieldName (). toStdString (),
resultComponentName (). toStdString (),
2019-02-15 09:37:17 +01:00
m_timeLapseBaseTimestep (),
2018-03-05 14:36:42 +01:00
resultFieldName (). toStdString () == RigFemPartResultsCollection :: FIELD_NAME_COMPACTION ? m_compactionRefLayer () : RigFemResultAddress :: NO_COMPACTION );
2016-10-10 16:09:54 +02:00
}
2018-06-18 14:17:13 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std :: vector < RigFemResultAddress > RimGeoMechResultDefinition :: observedResults () const
{
return std :: vector < RigFemResultAddress > ( 1 , resultAddress ());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemResultPosEnum RimGeoMechResultDefinition :: resultPositionType () const
{
return m_resultPositionType ();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimGeoMechResultDefinition :: resultFieldName () const
{
return m_resultFieldName ();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimGeoMechResultDefinition :: resultComponentName () const
{
return m_resultComponentName ();
}
2019-02-15 09:37:17 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimGeoMechResultDefinition :: diffResultUiName () const
{
QString diffResultString ;
if ( m_timeLapseBaseTimestep != RigFemResultAddress :: NO_TIME_LAPSE )
{
if ( m_geomCase -> geoMechData ())
{
std :: vector < std :: string > stepNames = m_geomCase -> geoMechData () -> femPartResults () -> filteredStepNames ();
QString timeStepString = QString :: fromStdString ( stepNames [ m_timeLapseBaseTimestep ()]);
diffResultString += QString ( "<b>Base Time Step</b>: %1" ). arg ( timeStepString );
}
}
return diffResultString ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimGeoMechResultDefinition :: diffResultUiShortName () const
{
QString diffResultString ;
if ( m_timeLapseBaseTimestep != RigFemResultAddress :: NO_TIME_LAPSE )
{
if ( m_geomCase -> geoMechData ())
{
diffResultString += QString ( "Base Time: #%1" ). arg ( m_timeLapseBaseTimestep ());
}
}
return diffResultString ;
}
2015-06-19 14:09:45 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigGeoMechCaseData * RimGeoMechResultDefinition :: ownerCaseData ()
{
2015-09-01 17:11:23 +02:00
return m_geomCase -> geoMechData ();
2015-06-19 14:09:45 +02:00
}
//--------------------------------------------------------------------------------------------------
2015-09-01 16:07:29 +02:00
/// Is the result probably valid and possible to load
2015-06-19 14:09:45 +02:00
//--------------------------------------------------------------------------------------------------
bool RimGeoMechResultDefinition :: hasResult ()
{
2018-06-11 13:47:21 +02:00
RigGeoMechCaseData * caseData = ownerCaseData ();
if ( caseData )
{
RigFemPartResultsCollection * results = caseData -> femPartResults ();
if ( results )
{
return results -> assertResultsLoaded ( this -> resultAddress ());
}
}
return false ;
2015-06-19 14:09:45 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimGeoMechResultDefinition :: resultFieldUiName ()
{
2019-02-15 09:37:17 +01:00
return convertToUiResultFieldName ( m_resultFieldName ());
2015-06-19 14:09:45 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimGeoMechResultDefinition :: resultComponentUiName ()
{
2019-02-15 09:37:17 +01:00
return m_resultComponentName ();
2015-06-19 14:09:45 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2019-02-15 09:37:17 +01:00
QString RimGeoMechResultDefinition :: convertToUiResultFieldName ( QString resultFieldName )
2015-06-19 14:09:45 +02:00
{
2016-10-10 16:37:13 +02:00
QString newName ( resultFieldName );
2015-06-19 14:09:45 +02:00
2016-10-10 16:37:13 +02:00
if ( resultFieldName == "E" ) newName = "NativeAbaqus Strain" ;
if ( resultFieldName == "S" ) newName = "NativeAbaqus Stress" ;
if ( resultFieldName == "NE" ) newName = "E" ; // Make NE and NS appear as E and SE
if ( resultFieldName == "POR-Bar" ) newName = "POR" ; // POR-Bar appear as POR
2018-01-15 17:40:39 +01:00
if ( resultFieldName == "MODULUS" ) newName = "Young's Modulus" ;
if ( resultFieldName == "RATIO" ) newName = "Poisson's Ratio" ;
2016-10-10 16:37:13 +02:00
return newName ;
2015-06-19 14:09:45 +02:00
}
2015-06-23 11:18:37 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-19 14:09:45 +02:00
void RimGeoMechResultDefinition :: setResultAddress ( const RigFemResultAddress & resultAddress )
{
m_resultPositionType = resultAddress . resultPosType ;
m_resultFieldName = QString :: fromStdString ( resultAddress . fieldName );
m_resultComponentName = QString :: fromStdString ( resultAddress . componentName );
2019-02-15 09:37:17 +01:00
m_timeLapseBaseTimestep = resultAddress . timeLapseBaseFrameIdx ;
m_compactionRefLayer = resultAddress . refKLayerIndex ;
2018-06-08 14:02:17 +02:00
2019-02-15 09:37:17 +01:00
m_resultPositionTypeUiField = m_resultPositionType ;
m_resultVariableUiField = composeFieldCompString ( m_resultFieldName (), m_resultComponentName ());
2018-02-15 10:58:13 +01:00
m_compactionRefLayerUiField = m_compactionRefLayer ;
2015-06-19 14:09:45 +02:00
}