Merge pull request #7960 from OPM/geomech_WIA4

GeoMech: Well Integrity Analysis
This commit is contained in:
jonjenssen 2021-09-09 17:34:27 +02:00 committed by GitHub
parent c603e6fe90
commit a5b80c649b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 2778 additions and 30 deletions

View File

@ -239,6 +239,7 @@
<file>redo.png</file>
<file>ComboBoxDown.svg</file>
<file>ComboBoxUp.svg</file>
<file>WellIntAnalysis.png</file>
</qresource>
<qresource prefix="/Shader">
<file>fs_CellFace.glsl</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

View File

@ -64,6 +64,14 @@ RiaPreferencesGeoMech::RiaPreferencesGeoMech()
m_geomechFRADefaultAdvXML.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
m_geomechFRADefaultAdvXML.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
CAF_PDM_InitFieldNoDefault( &m_geomechWIADefaultXML, "geomechWIADefaultXML", "Default Parameter XML File", "", "", "" );
m_geomechWIADefaultXML.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
m_geomechWIADefaultXML.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
CAF_PDM_InitFieldNoDefault( &m_geomechWIACommand, "geomechWIACommand", "Command to run", "", "", "" );
m_geomechWIACommand.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
m_geomechWIACommand.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
CAF_PDM_InitField( &m_keepTemporaryFiles,
"keepTemporaryFile",
false,
@ -88,18 +96,22 @@ RiaPreferencesGeoMech* RiaPreferencesGeoMech::current()
void RiaPreferencesGeoMech::appendItems( caf::PdmUiOrdering& uiOrdering ) const
{
caf::PdmUiGroup* faultRAGroup = uiOrdering.addNewGroup( "Fault Reactivation Assessment" );
caf::PdmUiGroup* cmdGroup = faultRAGroup->addNewGroup( "Commands (without parameters)" );
caf::PdmUiGroup* cmdFRAGroup = faultRAGroup->addNewGroup( "Commands (without parameters)" );
cmdGroup->add( &m_geomechFRAPreprocCommand );
cmdGroup->add( &m_geomechFRAPostprocCommand );
cmdGroup->add( &m_geomechFRAMacrisCommand );
cmdFRAGroup->add( &m_geomechFRAPreprocCommand );
cmdFRAGroup->add( &m_geomechFRAPostprocCommand );
cmdFRAGroup->add( &m_geomechFRAMacrisCommand );
caf::PdmUiGroup* paramGroup = faultRAGroup->addNewGroup( "Parameters" );
paramGroup->add( &m_geomechFRADefaultBasicXML );
paramGroup->add( &m_geomechFRADefaultAdvXML );
caf::PdmUiGroup* paramFRAGroup = faultRAGroup->addNewGroup( "Parameters" );
paramFRAGroup->add( &m_geomechFRADefaultBasicXML );
paramFRAGroup->add( &m_geomechFRADefaultAdvXML );
caf::PdmUiGroup* settingsGroup = faultRAGroup->addNewGroup( "Settings" );
settingsGroup->add( &m_keepTemporaryFiles );
caf::PdmUiGroup* wellIAGroup = uiOrdering.addNewGroup( "Well Integrity Analysis" );
wellIAGroup->add( &m_geomechWIACommand );
wellIAGroup->add( &m_geomechWIADefaultXML );
caf::PdmUiGroup* commonGroup = uiOrdering.addNewGroup( "Common Settings" );
commonGroup->add( &m_keepTemporaryFiles );
}
//--------------------------------------------------------------------------------------------------
@ -149,6 +161,22 @@ QString RiaPreferencesGeoMech::geomechFRADefaultAdvXML() const
return m_geomechFRADefaultAdvXML;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesGeoMech::geomechWIACommand() const
{
return m_geomechWIACommand;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesGeoMech::geomechWIADefaultXML() const
{
return m_geomechWIADefaultXML;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -169,12 +197,31 @@ bool RiaPreferencesGeoMech::validateFRASettings() const
files << geomechFRADefaultBasicXML();
files << geomechFRADefaultAdvXML();
return filesExists( files );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferencesGeoMech::validateWIASettings() const
{
QStringList files;
files << geomechWIACommand();
files << geomechWIADefaultXML();
return filesExists( files );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferencesGeoMech::filesExists( QStringList& files ) const
{
for ( int i = 0; i < files.size(); i++ )
{
if ( files[i].isEmpty() ) return false;
QFile file( files[i] );
if ( !file.exists() ) return false;
}
return true;
}

View File

@ -35,7 +35,9 @@ public:
static RiaPreferencesGeoMech* current();
void appendItems( caf::PdmUiOrdering& uiOrdering ) const;
bool validateFRASettings() const;
bool validateWIASettings() const;
// geomech settings
QString geomechFRAPreprocCommand() const;
@ -43,16 +45,26 @@ public:
QString geomechFRAMacrisCommand() const;
QString geomechFRADefaultBasicXML() const;
QString geomechFRADefaultAdvXML() const;
bool keepTemporaryFiles() const;
QString geomechWIADefaultXML() const;
QString geomechWIACommand() const;
bool keepTemporaryFiles() const;
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
private:
bool filesExists( QStringList& filelist ) const;
caf::PdmField<QString> m_geomechFRAPreprocCommand;
caf::PdmField<QString> m_geomechFRAPostprocCommand;
caf::PdmField<QString> m_geomechFRAMacrisCommand;
caf::PdmField<QString> m_geomechFRADefaultBasicXML;
caf::PdmField<QString> m_geomechFRADefaultAdvXML;
caf::PdmField<bool> m_keepTemporaryFiles;
caf::PdmField<QString> m_geomechWIADefaultXML;
caf::PdmField<QString> m_geomechWIACommand;
caf::PdmField<bool> m_keepTemporaryFiles;
};

View File

@ -14,6 +14,8 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicRunBasicFaultReactAssessment3dFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicRunAdvFaultReactAssessment3dFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicRunFaultReactAssessmentFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewWellIntegrityAnalysisFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicRunWellIntegrityAnalysisFeature.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -32,6 +34,8 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicRunBasicFaultReactAssessmentFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicRunBasicFaultReactAssessment3dFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicRunFaultReactAssessmentFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewWellIntegrityAnalysisFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicRunWellIntegrityAnalysisFeature.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@ -70,7 +70,8 @@ void RicNewFaultReactAssessmentFeature::onActionTriggered( bool isChecked )
{
QMessageBox::critical( nullptr,
"Fault Reactivation Assessment",
"Please go to ResInsight preferences and set/check the GeoMechanical settings!" );
"Fault Reactivation Assessment has not been properly set up.\nPlease go to ResInsight "
"preferences and set/check the GeoMechanical settings." );
return;
}

View File

@ -0,0 +1,109 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- 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 "RicNewWellIntegrityAnalysisFeature.h"
#include "RiaApplication.h"
#include "RiaPreferencesGeoMech.h"
#include "RimGeoMechView.h"
#include "RimProject.h"
#include "RimWellIASettings.h"
#include "RimWellIASettingsCollection.h"
#include "RimWellPath.h"
#include "Riu3DMainWindowTools.h"
#include "Riu3dSelectionManager.h"
#include "RiuFileDialogTools.h"
#include <QAction>
#include <QMessageBox>
CAF_CMD_SOURCE_INIT( RicNewWellIntegrityAnalysisFeature, "RicNewWellIntegrityAnalysisFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewWellIntegrityAnalysisFeature::onActionTriggered( bool isChecked )
{
RiuWellPathSelectionItem* wellPathItem = RiuWellPathSelectionItem::wellPathSelectionItem();
if ( !wellPathItem ) return;
RimWellPath* wellPath = wellPathItem->m_wellpath;
if ( !wellPath ) return;
RimWellIASettingsCollection* coll = wellPath->wellIASettingsCollection();
if ( !coll ) return;
RimGeoMechView* view = dynamic_cast<RimGeoMechView*>( RiaApplication::instance()->activeGridView() );
RimGeoMechCase* theCase = nullptr;
if ( view )
{
theCase = view->geoMechCase();
}
if ( !RiaPreferencesGeoMech::current()->validateWIASettings() )
{
QMessageBox::critical( nullptr,
"Well Integrity Analysis",
"Well Integrity Analysis has not been properly set up.\nPlease go to ResInsight "
"preferences and set / check the GeoMechanical settings." );
return;
}
// get base directory for our work, should be a new, empty folder somewhere
QString defaultDir =
RiaApplication::instance()->lastUsedDialogDirectoryWithFallbackToProjectFolder( "WELL_INTEGRITY_ANALYSIS" );
QString baseDir = RiuFileDialogTools::getExistingDirectory( nullptr, tr( "Select Working Directory" ), defaultDir );
if ( baseDir.isNull() || baseDir.isEmpty() ) return;
RiaApplication::instance()->setLastUsedDialogDirectory( "WELL_INTEGRITY_ANALYSIS", baseDir );
QString errMsg;
RimWellIASettings* newWIA =
coll->startWellIntegrationAnalysis( baseDir, wellPath, wellPathItem->m_measuredDepth, theCase, errMsg );
if ( newWIA )
{
wellPath->updateConnectedEditors();
Riu3DMainWindowTools::selectAsCurrentItem( newWIA );
newWIA->updateVisualization();
}
else
{
QMessageBox::critical( nullptr, "Well Integrity Analysis", errMsg );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewWellIntegrityAnalysisFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/WellIntAnalysis.png" ) );
actionToSetup->setText( "New Well Integration Analysis at this Depth" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewWellIntegrityAnalysisFeature::isCommandEnabled()
{
return true;
}

View File

@ -0,0 +1,36 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
#include <vector>
//==================================================================================================
///
//==================================================================================================
class RicNewWellIntegrityAnalysisFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
bool isCommandEnabled() override;
};

View File

@ -0,0 +1,114 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- 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 "RicRunWellIntegrityAnalysisFeature.h"
#include "RiaApplication.h"
#include "RiaPreferencesGeoMech.h"
#include "RifWellIAFileWriter.h"
#include "RimGeoMechView.h"
#include "RimProcess.h"
#include "RimProject.h"
#include "RimWellIASettings.h"
#include "RimWellIASettingsCollection.h"
#include "RimWellPath.h"
#include "Riu3DMainWindowTools.h"
#include "Riu3dSelectionManager.h"
#include "RiuFileDialogTools.h"
#include "cafProgressInfo.h"
#include "cafSelectionManagerTools.h"
#include <QAction>
#include <QMessageBox>
CAF_CMD_SOURCE_INIT( RicRunWellIntegrityAnalysisFeature, "RicRunWellIntegrityAnalysisFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRunWellIntegrityAnalysisFeature::onActionTriggered( bool isChecked )
{
RimWellIASettings* modelSettings =
dynamic_cast<RimWellIASettings*>( caf::SelectionManager::instance()->selectedItem() );
if ( modelSettings == nullptr ) return;
const QString wiaTitle( "Well Integrity Analysis" );
QString outErrorText;
caf::ProgressInfo runProgress( 3, wiaTitle + " running , please wait..." );
runProgress.setProgressDescription( "Writing input files." );
modelSettings->extractModelData();
if ( !RifWellIAFileWriter::writeToJsonFile( *modelSettings, outErrorText ) )
{
QMessageBox::critical( nullptr, wiaTitle, outErrorText );
return;
}
if ( !RifWellIAFileWriter::writeToCSVFile( *modelSettings, outErrorText ) )
{
QMessageBox::critical( nullptr, wiaTitle, outErrorText );
return;
}
runProgress.incrementProgress();
runProgress.setProgressDescription( "Running Abaqus modeling." );
QString command = RiaPreferencesGeoMech::current()->geomechWIACommand();
QStringList parameters = modelSettings->commandParameters();
RimProcess process;
process.setCommand( command );
process.setParameters( parameters );
if ( !process.execute() )
{
QMessageBox::critical( nullptr, wiaTitle, "Failed to run modeling. Check log window for additional information." );
return;
}
runProgress.incrementProgress();
runProgress.setProgressDescription( "Loading modeling results." );
// TODO - load results from Abaqus modeling here.
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRunWellIntegrityAnalysisFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/WellIntAnalysis.png" ) );
actionToSetup->setText( "Run..." );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicRunWellIntegrityAnalysisFeature::isCommandEnabled()
{
return true;
}

View File

@ -0,0 +1,36 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
#include <vector>
//==================================================================================================
///
//==================================================================================================
class RicRunWellIntegrityAnalysisFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
bool isCommandEnabled() override;
};

View File

@ -66,6 +66,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RifEnsembleFractureStatisticsExporter.h
${CMAKE_CURRENT_LIST_DIR}/RifSummaryReaderMultipleFiles.h
${CMAKE_CURRENT_LIST_DIR}/RifEclEclipseSummary.h
${CMAKE_CURRENT_LIST_DIR}/RifWellIAFileWriter.h
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
# ${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.h
)
@ -136,6 +137,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RifEnsembleFractureStatisticsExporter.cpp
${CMAKE_CURRENT_LIST_DIR}/RifSummaryReaderMultipleFiles.cpp
${CMAKE_CURRENT_LIST_DIR}/RifEclEclipseSummary.cpp
${CMAKE_CURRENT_LIST_DIR}/RifWellIAFileWriter.cpp
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
# ${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.cpp
)

View File

@ -21,6 +21,7 @@
#include "RimDoubleParameter.h"
#include "RimGenericParameter.h"
#include "RimIntegerParameter.h"
#include "RimListParameter.h"
#include "RimStringParameter.h"
#include "RimParameterGroup.h"
@ -52,6 +53,10 @@ RimGenericParameter* getParameterFromTypeStr( QString typestr )
{
return new RimStringParameter();
}
else if ( typestr == "list" )
{
return new RimListParameter();
}
return nullptr;
}
@ -76,7 +81,8 @@ bool RifParameterXmlReader::parseFile( QString& outErrorText )
RimParameterGroup* group = nullptr;
std::list<QString> reqattrs = { QString( "name" ), QString( "label" ), QString( "type" ) };
std::list<QString> reqGroupAttrs = { QString( "name" ) };
std::list<QString> reqParamAttrs = { QString( "name" ), QString( "label" ), QString( "type" ) };
bool bResult = true;
@ -91,15 +97,35 @@ bool RifParameterXmlReader::parseFile( QString& outErrorText )
m_parameters.push_back( group );
}
// check that we have the required attributes
for ( auto& reqattr : reqGroupAttrs )
{
if ( !xml.attributes().hasAttribute( reqattr ) )
{
outErrorText += "Missing required attribute \"" + reqattr + "\" for a parameter group.";
bResult = false;
break;
}
}
if ( !bResult ) break;
group = new RimParameterGroup();
if ( xml.attributes().hasAttribute( "name" ) )
{
group->setName( xml.attributes().value( "name" ).toString() );
}
if ( xml.attributes().hasAttribute( "label" ) )
{
group->setName( xml.attributes().value( "label" ).toString() );
group->setLabel( xml.attributes().value( "label" ).toString() );
}
if ( xml.attributes().hasAttribute( "expanded" ) )
{
group->setExpanded( xml.attributes().value( "expanded" ).toString().toLower() == "true" );
}
if ( xml.attributes().hasAttribute( "comment" ) )
{
group->setComment( xml.attributes().value( "comment" ).toString() );
}
continue;
}
@ -108,7 +134,7 @@ bool RifParameterXmlReader::parseFile( QString& outErrorText )
if ( group == nullptr ) continue;
// check that we have the required attributes
for ( auto& reqattr : reqattrs )
for ( auto& reqattr : reqParamAttrs )
{
if ( !xml.attributes().hasAttribute( reqattr ) )
{
@ -117,6 +143,7 @@ bool RifParameterXmlReader::parseFile( QString& outErrorText )
break;
}
}
if ( !bResult ) break;
// get a parameter of the required type
QString paramtypestr = xml.attributes().value( "type" ).toString().toLower();

View File

@ -0,0 +1,159 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 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 "RifWellIAFileWriter.h"
#include "RimGenericParameter.h"
#include "RimParameterGroup.h"
#include "RimParameterGroups.h"
#include "RimWellIAModelData.h"
#include "RimWellIASettings.h"
#include <QFile>
#include <QTextStream>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifWellIAFileWriter::writeToJsonFile( RimWellIASettings& settings, QString& outErrorText )
{
QString filename = settings.jsonInputFilename();
outErrorText = "Unable to write to file \"" + filename + "\" - ";
QFile file( filename );
if ( file.open( QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text ) )
{
QTextStream stream( &file );
stream << "{" << endl;
stream << "\"comments\": \"All units are SI unless mentioned otherwise; temperature is in Celcius; use forward "
"slash (/) in 'directory' definition\","
<< endl;
stream << "\"directory\": \"" + settings.outputBaseDirectory() + "\"," << endl;
stream << "\"output_name\": \"" + settings.name() + "\"";
RimParameterGroups mergedGroups;
bool mergeInCommentParameter = true;
for ( auto& group : settings.inputParameterGroups() )
{
mergedGroups.mergeGroup( group, mergeInCommentParameter );
}
for ( auto& group : settings.resinsightParameterGroups() )
{
mergedGroups.mergeGroup( group, mergeInCommentParameter );
}
for ( auto& group : mergedGroups.groups() )
{
stream << "," << endl;
stream << "\"" + group->name() + "\": {" << endl;
const auto& parameters = group->parameters();
for ( size_t i = 0; i < parameters.size(); )
{
stream << " \"" + parameters[i]->name() + "\": " + parameters[i]->jsonValue();
i++;
if ( i < parameters.size() )
{
stream << ",";
}
stream << endl;
}
stream << " }";
}
stream << endl << "}" << endl;
file.close();
}
else
{
outErrorText += "Could not open file.";
return false;
}
outErrorText = "";
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifWellIAFileWriter::writeToCSVFile( RimWellIASettings& settings, QString& outErrorText )
{
QString filename = settings.csvInputFilename();
outErrorText = "Unable to write to file \"" + filename + "\" - ";
QFile file( filename );
if ( file.open( QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text ) )
{
QTextStream stream( &file );
stream << "Time_days, Pcasing_Pa, P_form_Pa, Temp_C,"
"U1-1,U2,U3,U1-2,U2,U3,U1-3,U2,U3,U1-4,U2,U3,U1-5,U2,U3,U1-6,U2,U3,U1-7,U2,U3,U1-8,U2,U3,"
"X,Y,Z,X2,Y,Z,X3,Y,Z,X4,Y,Z,X5,Y,Z,X6,Y,Z,X7,Y,Z,X8,Y,Z";
stream << endl;
for ( auto& modeldata : settings.modelData() )
{
stream << modeldata->dayOffset();
stream << ",";
stream << modeldata->casingPressure();
stream << ",";
stream << modeldata->formationPressure();
stream << ",";
stream << modeldata->temperature();
for ( auto& u : modeldata->displacements() )
{
stream << ",";
stream << u.x();
stream << ",";
stream << u.y();
stream << ",";
stream << u.z();
}
for ( auto& pos : settings.modelBoxVertices() )
{
stream << ",";
stream << pos.x();
stream << ",";
stream << pos.y();
stream << ",";
stream << pos.z();
}
stream << endl;
}
}
else
{
outErrorText += "Could not open file.";
return false;
}
outErrorText = "";
return true;
}

View File

@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
class RimWellIASettings;
class RifWellIAFileWriter
{
public:
static bool writeToJsonFile( RimWellIASettings& settings, QString& outErrorText );
static bool writeToCSVFile( RimWellIASettings& settings, QString& outErrorText );
private:
RifWellIAFileWriter(){};
};

View File

@ -59,6 +59,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RivPolylinePartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivCellFilterPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivDrawableSpheres.h
${CMAKE_CURRENT_LIST_DIR}/RivBoxGeometryGenerator.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -117,6 +118,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RivPolylinePartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivCellFilterPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivDrawableSpheres.cpp
${CMAKE_CURRENT_LIST_DIR}/RivBoxGeometryGenerator.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@ -0,0 +1,107 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- 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 "RivBoxGeometryGenerator.h"
#include "cafEffectGenerator.h"
#include "cvfBase.h"
#include "cvfDrawableGeo.h"
#include "cvfPart.h"
#include "cvfPrimitiveSetDirect.h"
#include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfStructGridGeometryGenerator.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> RivBoxGeometryGenerator::createBoxFromVertices( const std::vector<cvf::Vec3f>& vertices,
const cvf::Color3f color )
{
std::vector<cvf::Vec3f> boxVertices;
for ( int enumInt = cvf::StructGridInterface::POS_I; enumInt < cvf::StructGridInterface::NO_FACE; enumInt++ )
{
cvf::StructGridInterface::FaceType face = static_cast<cvf::StructGridInterface::FaceType>( enumInt );
cvf::ubyte faceConn[4];
cvf::StructGridInterface::cellFaceVertexIndices( face, faceConn );
for ( int n = 0; n < 4; n++ )
{
boxVertices.push_back( cvf::Vec3f( vertices[faceConn[n]] ) );
}
}
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
cvf::ref<cvf::Vec3fArray> cvfVertices = new cvf::Vec3fArray;
cvfVertices->assign( boxVertices );
if ( !( cvfVertices.notNull() && cvfVertices->size() != 0 ) ) return nullptr;
geo->setVertexArray( cvfVertices.p() );
cvf::ref<cvf::UIntArray> indices = lineIndicesFromQuadVertexArray( cvfVertices.p() );
cvf::ref<cvf::PrimitiveSetIndexedUInt> prim = new cvf::PrimitiveSetIndexedUInt( cvf::PT_LINES );
prim->setIndices( indices.p() );
geo->addPrimitiveSet( prim.p() );
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName( cvf::String( "RivBoxGeometryGenerator::createBoxFromVertices" ) );
part->setDrawable( geo.p() );
cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator effGen( color );
eff = effGen.generateUnCachedEffect();
part->setEffect( eff.p() );
return part;
}
cvf::ref<cvf::UIntArray> RivBoxGeometryGenerator::lineIndicesFromQuadVertexArray( const cvf::Vec3fArray* vertexArray )
{
// TODO - see issue #7890
CVF_ASSERT( vertexArray );
size_t numVertices = vertexArray->size();
int numQuads = static_cast<int>( numVertices / 4 );
CVF_ASSERT( numVertices % 4 == 0 );
cvf::ref<cvf::UIntArray> indices = new cvf::UIntArray;
indices->resize( numQuads * 8 );
#pragma omp parallel for
for ( int i = 0; i < numQuads; i++ )
{
int idx = 8 * i;
indices->set( idx + 0, i * 4 + 0 );
indices->set( idx + 1, i * 4 + 1 );
indices->set( idx + 2, i * 4 + 1 );
indices->set( idx + 3, i * 4 + 2 );
indices->set( idx + 4, i * 4 + 2 );
indices->set( idx + 5, i * 4 + 3 );
indices->set( idx + 6, i * 4 + 3 );
indices->set( idx + 7, i * 4 + 0 );
}
return indices;
}

View File

@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <cvfArray.h>
#include <cvfColor3.h>
#include <cvfVector3.h>
#include <vector>
namespace cvf
{
class Part;
} // namespace cvf
//==================================================================================================
///
//==================================================================================================
class RivBoxGeometryGenerator
{
public:
static cvf::ref<cvf::Part> createBoxFromVertices( const std::vector<cvf::Vec3f>& vertices, const cvf::Color3f color );
static cvf::ref<cvf::UIntArray> lineIndicesFromQuadVertexArray( const cvf::Vec3fArray* vertexArray );
private:
RivBoxGeometryGenerator(){};
};

View File

@ -37,6 +37,8 @@
#include "RimPerforationInterval.h"
#include "RimRegularLegendConfig.h"
#include "RimTools.h"
#include "RimWellIASettings.h"
#include "RimWellIASettingsCollection.h"
#include "RimWellMeasurement.h"
#include "RimWellMeasurementCollection.h"
#include "RimWellMeasurementFilter.h"
@ -53,6 +55,7 @@
#include "RimWellPathValve.h"
#include "Riv3dWellLogPlanePartMgr.h"
#include "RivBoxGeometryGenerator.h"
#include "RivDrawableSpheres.h"
#include "RivFishbonesSubsPartMgr.h"
#include "RivObjectSourceInfo.h"
@ -868,6 +871,7 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel( cvf::ModelBasicList*
appendFishboneSubsPartsToModel( model, displayCoordTransform, characteristicCellSize );
appendWellPathAttributesToModel( model, displayCoordTransform, characteristicCellSize );
appendWellIntegrityIntervalsToModel( model, displayCoordTransform, characteristicCellSize );
RimGridView* gridView = dynamic_cast<RimGridView*>( m_rimView.p() );
if ( gridView )
@ -1021,3 +1025,76 @@ double RivWellPathPartMgr::wellMeasurementRadius( double
return wellPathCollection->wellPathRadiusScaleFactor() * wellMeasurementInView->radiusScaleFactor() *
characteristicCellSize;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellPathPartMgr::appendWellIntegrityIntervalsToModel( cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
double characteristicCellSize )
{
if ( !m_rimWellPath ) return;
RimWellPathCollection* wellPathCollection = this->wellPathCollection();
if ( !wellPathCollection ) return;
RigWellPath* wellPathGeometry = m_rimWellPath->wellPathGeometry();
if ( !wellPathGeometry ) return;
// Since we're using the index of measured depths to find the index of a point, ensure they're equal
CVF_ASSERT( wellPathGeometry->measuredDepths().size() == wellPathGeometry->wellPathPoints().size() );
double wellPathRadius = this->wellPathRadius( characteristicCellSize, wellPathCollection );
double wiaIntervalRadius = wellPathRadius * 1.15;
RivPipeGeometryGenerator geoGenerator;
for ( auto wiaModel : m_rimWellPath->wellIASettingsCollection()->settings() )
{
if ( !wiaModel->isChecked() ) continue;
if ( wiaModel->startMD() > wiaModel->endMD() ) continue;
double horizontalLengthAlongWellPath = 0.0;
std::vector<cvf::Vec3d> intervalCL;
{
std::pair<std::vector<cvf::Vec3d>, std::vector<double>> intervalCoordsAndMD =
wellPathGeometry->clippedPointSubset( wiaModel->startMD(), wiaModel->endMD(), &horizontalLengthAlongWellPath );
intervalCL = intervalCoordsAndMD.first;
}
if ( intervalCL.size() < 2 ) continue;
std::vector<cvf::Vec3d> intervalCLDisplayCS;
for ( cvf::Vec3d& point : intervalCL )
{
intervalCLDisplayCS.push_back( displayCoordTransform->transformToDisplayCoord( point ) );
}
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo( wiaModel );
cvf::Collection<cvf::Part> parts;
geoGenerator.cylinderWithCenterLineParts( &parts, intervalCLDisplayCS, cvf::Color3f::ORCHID, wiaIntervalRadius );
for ( auto& part : parts )
{
part->setSourceInfo( objectSourceInfo.p() );
model->addPart( part.p() );
}
if ( wiaModel->showBox() )
{
const auto& vertices = wiaModel->modelBoxVertices();
std::vector<cvf::Vec3f> transformedVertices;
for ( auto& v : vertices )
{
transformedVertices.push_back( cvf::Vec3f( displayCoordTransform->transformToDisplayCoord( v ) ) );
}
cvf::ref<cvf::Part> boxpart =
RivBoxGeometryGenerator::createBoxFromVertices( transformedVertices, cvf::Color3f::ORCHID );
boxpart->setSourceInfo( objectSourceInfo.p() );
model->addPart( boxpart.p() );
}
}
}

View File

@ -98,7 +98,6 @@ private:
const caf::DisplayCoordTransform* displayCoordTransform,
double characteristicCellSize );
void appendPerforationsToModel( cvf::ModelBasicList* model,
size_t timeStepIndex,
const caf::DisplayCoordTransform* displayCoordTransform,
@ -116,6 +115,10 @@ private:
const caf::DisplayCoordTransform* displayCoordTransform,
double characteristicCellSize );
void appendWellIntegrityIntervalsToModel( cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
double characteristicCellSize );
void buildWellPathParts( const caf::DisplayCoordTransform* displayCoordTransform,
double characteristicCellSize,
const cvf::BoundingBox& wellPathClipBoundingBox,

View File

@ -3,7 +3,9 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimDoubleParameter.h
${CMAKE_CURRENT_LIST_DIR}/RimIntegerParameter.h
${CMAKE_CURRENT_LIST_DIR}/RimStringParameter.h
${CMAKE_CURRENT_LIST_DIR}/RimListParameter.h
${CMAKE_CURRENT_LIST_DIR}/RimParameterGroup.h
${CMAKE_CURRENT_LIST_DIR}/RimParameterGroups.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -11,7 +13,9 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimDoubleParameter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimIntegerParameter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimStringParameter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimListParameter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimParameterGroup.cpp
${CMAKE_CURRENT_LIST_DIR}/RimParameterGroups.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@ -84,3 +84,18 @@ double RimDoubleParameter::value() const
{
return m_value();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGenericParameter* RimDoubleParameter::duplicate() const
{
RimDoubleParameter* retval = new RimDoubleParameter();
retval->setName( name() );
retval->setValue( value() );
retval->setDescription( description() );
retval->setLabel( label() );
retval->setAdvanced( isAdvanced() );
return retval;
}

View File

@ -44,6 +44,8 @@ public:
double value() const;
virtual RimGenericParameter* duplicate() const;
private:
caf::PdmField<double> m_value;
};

View File

@ -143,3 +143,11 @@ QString RimGenericParameter::description() const
{
return m_description();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimGenericParameter::jsonValue() const
{
return stringValue();
}

View File

@ -43,6 +43,7 @@ public:
virtual void setValue( QString value ) = 0;
virtual QVariant variantValue() const = 0;
virtual QString stringValue() const = 0;
virtual QString jsonValue() const;
QString name() const;
QString label() const;
@ -50,6 +51,8 @@ public:
bool isAdvanced() const;
bool isValid() const;
virtual RimGenericParameter* duplicate() const = 0;
protected:
void setValid( bool valid );

View File

@ -69,6 +69,14 @@ QVariant RimIntegerParameter::variantValue() const
return QVariant( m_value() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimIntegerParameter::value() const
{
return m_value();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -76,3 +84,18 @@ QString RimIntegerParameter::stringValue() const
{
return QString::number( m_value() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGenericParameter* RimIntegerParameter::duplicate() const
{
RimIntegerParameter* retval = new RimIntegerParameter();
retval->setName( name() );
retval->setValue( value() );
retval->setDescription( description() );
retval->setLabel( label() );
retval->setAdvanced( isAdvanced() );
return retval;
}

View File

@ -41,6 +41,9 @@ public:
void setValue( QString value ) override;
QVariant variantValue() const override;
QString stringValue() const override;
int value() const;
RimGenericParameter* duplicate() const override;
private:
caf::PdmField<int> m_value;

View File

@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 - 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 "RimListParameter.h"
#include <cmath>
CAF_PDM_SOURCE_INIT( RimListParameter, "ListParameter" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimListParameter::RimListParameter()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimListParameter::~RimListParameter()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimListParameter::jsonValue() const
{
return stringValue();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGenericParameter* RimListParameter::duplicate() const
{
RimListParameter* retval = new RimListParameter();
retval->setName( name() );
retval->setValue( stringValue() );
retval->setDescription( description() );
retval->setLabel( label() );
retval->setAdvanced( isAdvanced() );
return retval;
}

View File

@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 - 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include <QString>
#include "RimStringParameter.h"
//==================================================================================================
///
///
//==================================================================================================
class RimListParameter : public RimStringParameter
{
CAF_PDM_HEADER_INIT;
public:
RimListParameter();
~RimListParameter() override;
QString jsonValue() const override;
RimGenericParameter* duplicate() const override;
};

View File

@ -49,9 +49,24 @@ RimParameterGroup::RimParameterGroup()
m_name.uiCapability()->setUiHidden( true );
m_name.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitFieldNoDefault( &m_label, "Label", "Label", "", "", "" );
m_label.uiCapability()->setUiHidden( true );
m_label.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitFieldNoDefault( &m_comment, "Comment", "Comment", "", "", "" );
m_comment.uiCapability()->setUiHidden( true );
m_comment.uiCapability()->setUiReadOnly( true );
m_comment.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitFieldNoDefault( &m_showExpanded, "Expanded", "Expanded", "", "", "" );
m_name.uiCapability()->setUiHidden( true );
m_name.uiCapability()->setUiReadOnly( true );
m_showExpanded.uiCapability()->setUiHidden( true );
m_showExpanded.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitFieldNoDefault( &m_labelProxy, "LabelProxy", "Label Proxy", "", "", "" );
m_labelProxy.registerGetMethod( this, &RimParameterGroup::labelOrName );
m_labelProxy.uiCapability()->setUiReadOnly( true );
m_labelProxy.uiCapability()->setUiHidden( true );
m_labelProxy.xmlCapability()->disableIO();
}
//--------------------------------------------------------------------------------------------------
@ -66,7 +81,16 @@ RimParameterGroup::~RimParameterGroup()
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimParameterGroup::userDescriptionField()
{
return &m_name;
return &m_labelProxy;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimParameterGroup::labelOrName() const
{
if ( m_label().isEmpty() ) return m_name;
return m_label;
}
//--------------------------------------------------------------------------------------------------
@ -87,7 +111,7 @@ void RimParameterGroup::addParameter( QString name, int value )
p->setLabel( name );
p->setValue( value );
m_parameters.push_back( p );
addParameter( p );
}
//--------------------------------------------------------------------------------------------------
@ -100,7 +124,7 @@ void RimParameterGroup::addParameter( QString name, QString value )
p->setLabel( name );
p->setValue( value );
m_parameters.push_back( p );
addParameter( p );
}
//--------------------------------------------------------------------------------------------------
@ -113,7 +137,7 @@ void RimParameterGroup::addParameter( QString name, double value )
p->setLabel( name );
p->setValue( value );
m_parameters.push_back( p );
addParameter( p );
}
//--------------------------------------------------------------------------------------------------
@ -151,7 +175,8 @@ void RimParameterGroup::defineEditorAttribute( const caf::PdmFieldHandle* field,
//--------------------------------------------------------------------------------------------------
void RimParameterGroup::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
auto group = uiOrdering.addNewGroup( name() );
auto group = uiOrdering.addNewGroup( label() );
if ( !m_comment().isEmpty() ) group->add( &m_comment );
group->add( &m_parameters );
uiOrdering.skipRemainingFields( true );
@ -165,6 +190,22 @@ void RimParameterGroup::setName( QString name )
m_name = name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimParameterGroup::setLabel( QString label )
{
m_label = label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimParameterGroup::setComment( QString comment )
{
m_comment = comment;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -189,6 +230,22 @@ QString RimParameterGroup::name() const
return m_name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimParameterGroup::comment() const
{
return m_comment;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimParameterGroup::label() const
{
return labelOrName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -237,3 +294,16 @@ RimGenericParameter* RimParameterGroup::parameter( QString name ) const
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QVariant RimParameterGroup::parameterValue( QString name ) const
{
RimGenericParameter* p = parameter( name );
if ( p )
{
return p->variantValue();
}
return QVariant();
}

View File

@ -21,8 +21,10 @@
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmProxyValueField.h"
#include <QString>
#include <QVariant>
#include <vector>
class RimGenericParameter;
@ -47,6 +49,8 @@ public:
void appendParametersToList( std::list<RimGenericParameter*>& parameterList );
void setName( QString name );
void setLabel( QString label );
void setComment( QString comment );
void setExpanded( bool expand );
void setParameterValue( QString name, int value );
@ -55,20 +59,28 @@ public:
bool isExpanded() const;
QString name() const;
QString comment() const;
QString label() const;
std::vector<RimGenericParameter*> parameters() const;
RimGenericParameter* parameter( QString name ) const;
QVariant parameterValue( QString name ) const;
private:
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
caf::PdmFieldHandle* userDescriptionField() override;
QString labelOrName() const;
private:
caf::PdmChildArrayField<RimGenericParameter*> m_parameters;
caf::PdmField<bool> m_showExpanded;
caf::PdmField<QString> m_name;
caf::PdmField<QString> m_label;
caf::PdmField<QString> m_comment;
caf::PdmProxyValueField<QString> m_labelProxy;
};

View File

@ -0,0 +1,92 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- 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 "RimParameterGroups.h"
#include "RimGenericParameter.h"
#include "RimParameterGroup.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimParameterGroups::RimParameterGroups()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimParameterGroups::~RimParameterGroups()
{
clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimParameterGroups::clear()
{
for ( const auto& [key, value] : m_groups )
{
delete value;
}
m_groups.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimParameterGroups::mergeGroup( RimParameterGroup* group, bool addCommentAsParameter /* = false */ )
{
const QString grpName = group->name();
if ( m_groups.count( grpName ) == 0 )
{
RimParameterGroup* newGroup = new RimParameterGroup();
newGroup->setName( grpName );
newGroup->setLabel( group->label() );
newGroup->setComment( group->comment() );
if ( addCommentAsParameter && !newGroup->comment().isEmpty() )
{
newGroup->addParameter( "comments", newGroup->comment() );
}
m_groups[grpName] = newGroup;
}
RimParameterGroup* dstGroup = m_groups[grpName];
for ( auto& parameter : group->parameters() )
{
dstGroup->addParameter( parameter->duplicate() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<RimParameterGroup*> RimParameterGroups::groups() const
{
std::vector<RimParameterGroup*> retGroups;
for ( const auto& [key, value] : m_groups )
{
retGroups.push_back( value );
}
return retGroups;
}

View File

@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 - 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
#include <map>
#include <vector>
class RimParameterGroup;
//==================================================================================================
///
///
//==================================================================================================
class RimParameterGroups
{
public:
RimParameterGroups();
~RimParameterGroups();
void mergeGroup( RimParameterGroup* group, bool addCommentAsParameter = false );
const std::vector<RimParameterGroup*> groups() const;
void clear();
private:
std::map<QString, RimParameterGroup*> m_groups;
};

View File

@ -66,3 +66,26 @@ QString RimStringParameter::stringValue() const
{
return m_value();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimStringParameter::jsonValue() const
{
return QString( "\"%1\"" ).arg( stringValue() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGenericParameter* RimStringParameter::duplicate() const
{
RimStringParameter* retval = new RimStringParameter();
retval->setName( name() );
retval->setValue( stringValue() );
retval->setDescription( description() );
retval->setLabel( label() );
retval->setAdvanced( isAdvanced() );
return retval;
}

View File

@ -40,6 +40,9 @@ public:
void setValue( QString value ) override;
QVariant variantValue() const override;
QString stringValue() const override;
QString jsonValue() const override;
RimGenericParameter* duplicate() const override;
private:
caf::PdmField<QString> m_value;

View File

@ -137,6 +137,7 @@
#include "RimViewLinkerCollection.h"
#include "RimVirtualPerforationResults.h"
#include "RimWellAllocationPlot.h"
#include "RimWellIASettings.h"
#include "RimWellLogCurve.h"
#include "RimWellLogFile.h"
#include "RimWellLogFileChannel.h"
@ -1099,9 +1100,9 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicNewMultiPlotFeature";
// Work in progress -- End
appendCreateCompletions( menuBuilder, menuBuilder.itemCount() > 0u );
bool addedExportWellPaths = appendExportWellPaths( menuBuilder, menuBuilder.itemCount() > 0u ) > 0;
appendExportCompletions( menuBuilder, menuBuilder.itemCount() > 0u && !addedExportWellPaths );
appendExportWellPaths( menuBuilder, menuBuilder.itemCount() > 0u );
if ( menuBuilder.itemCount() > 0u )
{
@ -1177,6 +1178,12 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "Separator";
menuBuilder << "RicNewSimWellFractureFeature";
}
#ifdef USE_ODB_API
else if ( dynamic_cast<RimWellIASettings*>( firstUiItem ) )
{
menuBuilder << "RicRunWellIntegrityAnalysisFeature";
}
#endif
menuBuilder.addSeparator();
menuBuilder << "RicCopyIntersectionsToAllViewsInCaseFeature";
}

View File

@ -10,6 +10,11 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimWellPathCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPathTarget.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPathTieIn.h
${CMAKE_CURRENT_LIST_DIR}/RimWellIASettings.h
${CMAKE_CURRENT_LIST_DIR}/RimWellIASettingsCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimWellIAModelBox.h
${CMAKE_CURRENT_LIST_DIR}/RimWellIAModelData.h
${CMAKE_CURRENT_LIST_DIR}/RimWellIADataAccess.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -24,6 +29,11 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimWellPathGroup.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathTarget.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathTieIn.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellIASettings.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellIASettingsCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellIAModelBox.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellIAModelData.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellIADataAccess.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@ -0,0 +1,130 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 - 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 "RimWellIADataAccess.h"
#include "RigFemClosestResultIndexCalculator.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
#include "RigGeoMechCaseData.h"
#include "RimGeoMechCase.h"
#include "../cafHexInterpolator/cafHexInterpolator.h" // Use relative path, as this is a header only file not part of a library
#include "cvfBoundingBox.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellIADataAccess::RimWellIADataAccess( RimGeoMechCase* thecase )
: m_case( thecase )
, m_caseData( nullptr )
{
if ( m_case ) m_caseData = m_case->geoMechData();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellIADataAccess::~RimWellIADataAccess()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimWellIADataAccess::resultIndex( RigFemResultPosEnum resultType, cvf::Vec3d position )
{
int closestCell = elementIndex( position );
if ( closestCell < 0 ) return -1;
RigFemClosestResultIndexCalculator closestIndexCalc( m_caseData->femParts()->part( 0 ), resultType, closestCell, -1, position );
return closestIndexCalc.resultIndexToClosestResult();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimWellIADataAccess::elementIndex( cvf::Vec3d position )
{
cvf::BoundingBox bb;
bb.add( position );
std::vector<size_t> closeCells;
m_caseData->femParts()->part( 0 )->findIntersectingCells( bb, &closeCells );
if ( closeCells.size() == 0 ) return -1;
return (int)closeCells[0];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimWellIADataAccess::resultValue( QString fieldName,
QString componentName,
RigFemResultPosEnum resultType,
size_t resultIndex,
int timeStep )
{
RigFemResultAddress address( resultType, fieldName.toStdString(), componentName.toStdString() );
const std::vector<float>& scalarResults = m_caseData->femPartResults()->resultValues( address, 0, timeStep );
if ( resultIndex < scalarResults.size() ) return scalarResults[resultIndex];
return 0.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimWellIADataAccess::interpolatedResultValue( QString fieldName,
QString componentName,
RigFemResultPosEnum resultType,
cvf::Vec3d position,
int timeStep )
{
RigFemResultAddress address( resultType, fieldName.toStdString(), componentName.toStdString() );
int elmIdx = elementIndex( position );
RigFemPart* femPart = m_caseData->femParts()->part( 0 );
RigElementType elmType = femPart->elementType( elmIdx );
const int* elementConn = femPart->connectivities( elmIdx );
int elmNodeCount = RigFemTypes::elementNodeCount( elmType );
const std::vector<float>& scalarResults = m_caseData->femPartResults()->resultValues( address, 0, timeStep );
std::array<double, 8> nodeResults;
std::array<cvf::Vec3d, 8> nodeCorners;
for ( int lNodeIdx = 0; lNodeIdx < elmNodeCount; ++lNodeIdx )
{
int nodeIdx = elementConn[lNodeIdx];
size_t resIdx = femPart->resultValueIdxFromResultPosType( resultType, elmIdx, lNodeIdx );
if ( resIdx >= scalarResults.size() )
nodeResults[lNodeIdx] = 0.0;
else
nodeResults[lNodeIdx] = scalarResults[resIdx];
nodeCorners[lNodeIdx] = cvf::Vec3d( femPart->nodes().coordinates[nodeIdx] );
}
return caf::HexInterpolator::interpolateHex( nodeCorners, nodeResults, position );
}

View File

@ -0,0 +1,58 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 - 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RigFemResultPosEnum.h"
#include "cvfVector3.h"
#include <QString>
#include <vector>
class RimGeoMechCase;
class RigGeoMechCaseData;
//==================================================================================================
///
///
//==================================================================================================
class RimWellIADataAccess
{
public:
RimWellIADataAccess( RimGeoMechCase* thecase );
~RimWellIADataAccess();
int resultIndex( RigFemResultPosEnum resultType, cvf::Vec3d position );
int elementIndex( cvf::Vec3d position );
double resultValue( QString fieldName,
QString componentName,
RigFemResultPosEnum resultType,
size_t resultIndex,
int timeStep );
double interpolatedResultValue( QString fieldname,
QString componentName,
RigFemResultPosEnum resultType,
cvf::Vec3d position,
int timeStep );
private:
RimGeoMechCase* m_case;
RigGeoMechCaseData* m_caseData;
};

View File

@ -0,0 +1,109 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 - 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 "RimWellIAModelBox.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellIAModelBox::RimWellIAModelBox()
{
m_vertices.resize( 8 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellIAModelBox::~RimWellIAModelBox()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RimWellIAModelBox::vertices() const
{
return m_vertices;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RimWellIAModelBox::center() const
{
return m_center;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellIAModelBox::updateBox( cvf::Vec3d startPos, cvf::Vec3d endPos, double xyBuffer, double depthBuffer )
{
m_center = startPos + endPos;
m_center /= 2.0;
cvf::Vec3d upwards = startPos - endPos;
upwards.normalize();
cvf::Vec3d downwards = upwards * -1.0;
cvf::Vec3d xdir = upwards.perpendicularVector();
xdir.normalize();
cvf::Vec3d ydir = upwards ^ xdir;
ydir.normalize();
cvf::Vec3d topCenter = startPos + upwards * depthBuffer;
cvf::Vec3d bottomCenter = endPos + downwards * depthBuffer;
std::vector<cvf::Vec3d> topVertices = generateRectangle( topCenter, xdir, ydir, xyBuffer );
std::vector<cvf::Vec3d> bottomVertices = generateRectangle( bottomCenter, xdir, ydir, xyBuffer );
for ( size_t i = 0; i < 4; i++ )
{
m_vertices[i] = bottomVertices[i];
m_vertices[i + 4] = topVertices[i];
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d>
RimWellIAModelBox::generateRectangle( cvf::Vec3d center, cvf::Vec3d unitX, cvf::Vec3d unitY, double buffer )
{
std::vector<cvf::Vec3d> corners;
corners.resize( 4 );
corners[0] = center;
corners[0] -= unitX * buffer;
corners[0] -= unitY * buffer;
corners[1] = center;
corners[1] += unitX * buffer;
corners[1] -= unitY * buffer;
corners[2] = center;
corners[2] += unitX * buffer;
corners[2] += unitY * buffer;
corners[3] = center;
corners[3] -= unitX * buffer;
corners[3] += unitY * buffer;
return corners;
}

View File

@ -0,0 +1,47 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 - 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfVector3.h"
#include <QString>
#include <map>
#include <vector>
//==================================================================================================
///
///
//==================================================================================================
class RimWellIAModelBox
{
public:
RimWellIAModelBox();
~RimWellIAModelBox();
std::vector<cvf::Vec3d> vertices() const;
cvf::Vec3d center() const;
bool updateBox( cvf::Vec3d startPos, cvf::Vec3d endPos, double xyBuffer, double depthBuffer );
private:
std::vector<cvf::Vec3d> generateRectangle( cvf::Vec3d center, cvf::Vec3d unitX, cvf::Vec3d unitY, double buffer );
std::vector<cvf::Vec3d> m_vertices;
cvf::Vec3d m_center;
};

View File

@ -0,0 +1,120 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 - 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 "RimWellIAModelData.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellIAModelData::RimWellIAModelData()
{
m_displacements.resize( 8 );
m_casingPressure = 0.0;
m_formationPressure = 0.0;
m_temperature = 0.0;
m_dayoffset = 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellIAModelData::~RimWellIAModelData()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RimWellIAModelData::displacements() const
{
return m_displacements;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIAModelData::setDisplacement( int cornerIndex, cvf::Vec3d displacement )
{
size_t ci = cornerIndex;
if ( ( cornerIndex >= 0 ) && ( ci < m_displacements.size() ) ) m_displacements[ci] = displacement;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIAModelData::setCasingPressure( double pressure )
{
m_casingPressure = pressure;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimWellIAModelData::casingPressure() const
{
return m_casingPressure;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIAModelData::setFormationPressure( double pressure )
{
m_formationPressure = pressure;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimWellIAModelData::formationPressure() const
{
return m_formationPressure;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIAModelData::setTemperature( double temp )
{
m_temperature = temp;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimWellIAModelData::temperature() const
{
return m_temperature;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimWellIAModelData::dayOffset() const
{
return m_dayoffset;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIAModelData::setDayOffset( int days )
{
m_dayoffset = days;
}

View File

@ -0,0 +1,58 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 - 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfVector3.h"
#include <QString>
#include <map>
#include <vector>
//==================================================================================================
///
///
//==================================================================================================
class RimWellIAModelData
{
public:
RimWellIAModelData();
~RimWellIAModelData();
std::vector<cvf::Vec3d> displacements() const;
void setDisplacement( int cornerIndex, cvf::Vec3d displacement );
void setCasingPressure( double pressure );
double casingPressure() const;
void setFormationPressure( double pressure );
double formationPressure() const;
void setTemperature( double temp );
double temperature() const;
int dayOffset() const;
void setDayOffset( int days );
private:
std::vector<cvf::Vec3d> m_displacements;
double m_casingPressure;
double m_formationPressure;
double m_temperature;
int m_dayoffset;
};

View File

@ -0,0 +1,640 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 - 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 "RimWellIASettings.h"
#include "RiaApplication.h"
#include "RiaPreferencesGeoMech.h"
#include "RigWellPath.h"
#include "RigWellPathGeometryTools.h"
#include "RimDoubleParameter.h"
#include "RimGenericParameter.h"
#include "RimGeoMechCase.h"
#include "RimIntegerParameter.h"
#include "RimParameterGroup.h"
#include "RimProject.h"
#include "RimStringParameter.h"
#include "RimTools.h"
#include "RimWellIADataAccess.h"
#include "RimWellIAModelData.h"
#include "RimWellPath.h"
#include "RifParameterXmlReader.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiComboBoxEditor.h"
#include "cafPdmUiDateEditor.h"
#include "cafPdmUiDoubleSliderEditor.h"
#include "cafPdmUiFilePathEditor.h"
#include "cafPdmUiTableViewEditor.h"
#include <QDebug>
#include <QFileInfo>
#include <cmath>
CAF_PDM_SOURCE_INIT( RimWellIASettings, "RimWellIASettings" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellIASettings::RimWellIASettings()
{
CAF_PDM_InitObject( "Integrity Analysis Model Settings", ":/WellIntAnalysis.png", "", "" );
setName( "Model" );
CAF_PDM_InitFieldNoDefault( &m_geomechCase, "GeomechCase", "GeoMech Case", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_baseDir, "BaseDir", "Working Directory", "", "", "" );
m_baseDir.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitField( &m_startMD, "StartMeasuredDepth", 0.0, "Start MD", "", "", "" );
CAF_PDM_InitField( &m_endMD, "EndMeasuredDepth", 0.0, "End MD", "", "", "" );
m_startMD.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
m_endMD.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_bufferXY, "BufferXY", 20.0, "Model Size (XY)", "", "", "" );
CAF_PDM_InitField( &m_bufferZ, "BufferZ", 15.0, "Depth buffer size", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_parameters, "ModelingParameters", "Modeling Parameters", ":/Bullet.png", "", "" );
CAF_PDM_InitFieldNoDefault( &m_csvParameters, "TimeStepParameters", "Time Step Parameters", ":/Bullet.png", "", "" );
CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name Proxy", "", "", "" );
m_nameProxy.registerGetMethod( this, &RimWellIASettings::fullName );
m_nameProxy.uiCapability()->setUiReadOnly( true );
m_nameProxy.uiCapability()->setUiHidden( true );
m_nameProxy.xmlCapability()->disableIO();
CAF_PDM_InitField( &m_showBox, "showBox", false, "Show model box", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_geostaticDate, "startDate", "Start Date (geostatic):", "", "", "" );
CAF_PDM_InitField( &m_boxValid, "boxValid", false, "Model box is valid", "", "", "" );
m_boxValid.uiCapability()->setUiHidden( true );
this->setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellIASettings::~RimWellIASettings()
{
resetResInsightParameters();
resetModelData();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellIASettings::initSettings( QString& outErrmsg )
{
initCsvParameters();
RifParameterXmlReader basicreader( RiaPreferencesGeoMech::current()->geomechWIADefaultXML() );
if ( !basicreader.parseFile( outErrmsg ) ) return false;
m_parameters.clear();
for ( auto group : basicreader.parameterGroups() )
{
m_parameters.push_back( group );
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettings::updateVisualization()
{
generateModelBox();
RiaApplication::instance()->project()->scheduleCreateDisplayModelAndRedrawAllViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettings::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
if ( ( changedField == &m_startMD ) || ( changedField == &m_endMD ) || ( changedField == objectToggleField() ) ||
( changedField == &m_bufferXY ) || ( changedField == &m_bufferZ ) || ( changedField == &m_showBox ) )
{
updateVisualization();
}
this->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimWellIASettings::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_geomechCase )
{
RimTools::geoMechCaseOptionItems( &options );
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettings::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
RimWellPath* wellPath;
firstAncestorOrThisOfType( wellPath );
if ( wellPath )
{
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
{
m_startMD.uiCapability()->setUiName( "Start MD [m]" );
m_endMD.uiCapability()->setUiName( "End MD [m]" );
}
else if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
{
m_startMD.uiCapability()->setUiName( "Start MD [ft]" );
m_endMD.uiCapability()->setUiName( "End MD [ft]" );
}
}
auto generalGroup = uiOrdering.addNewGroup( "General" );
generalGroup->add( nameField() );
generalGroup->add( &m_baseDir );
auto geoGroup = uiOrdering.addNewGroup( "GeoMechanical Settings" );
geoGroup->add( &m_geomechCase );
geoGroup->add( &m_geostaticDate );
auto modelGroup = uiOrdering.addNewGroup( "Model Settings" );
modelGroup->add( &m_startMD );
modelGroup->add( &m_endMD );
modelGroup->add( &m_bufferXY );
modelGroup->add( &m_bufferZ );
modelGroup->add( &m_showBox );
uiOrdering.skipRemainingFields( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettings::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_startMD || field == &m_endMD )
{
caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute );
if ( myAttr )
{
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfType( wellPath );
if ( !wellPath ) return;
myAttr->m_minimum = wellPath->uniqueStartMD();
myAttr->m_maximum = wellPath->uniqueEndMD();
}
}
else if ( field == &m_geostaticDate )
{
caf::PdmUiDateEditorAttribute* myAttr = dynamic_cast<caf::PdmUiDateEditorAttribute*>( attribute );
if ( myAttr )
{
myAttr->dateFormat = "dd MMM yyyy";
}
}
}
//--------------------------------------------------------------------------------------------------
/// Return the name to show in the tree selector
//--------------------------------------------------------------------------------------------------
QString RimWellIASettings::fullName() const
{
return QString( "%1 - [%2 - %3]" ).arg( name() ).arg( m_startMD ).arg( m_endMD );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellIASettings::modelBoxValid() const
{
return m_boxValid;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RimWellIASettings::modelBoxVertices() const
{
return m_modelbox.vertices();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimWellIAModelData*> RimWellIASettings::modelData() const
{
return m_modelData;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimWellIASettings::userDescriptionField()
{
return &m_nameProxy;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellIASettings::geomechCaseFilename() const
{
if ( m_geomechCase ) return m_geomechCase->gridFileName();
return "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellIASettings::geomechCaseName() const
{
QFileInfo fi( geomechCaseFilename() );
return fi.baseName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechCase* RimWellIASettings::geomechCase() const
{
return m_geomechCase;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QDateTime RimWellIASettings::geostaticDate() const
{
return m_geostaticDate;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellIASettings::outputBaseDirectory() const
{
return m_baseDir();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellIASettings::jsonInputFilename() const
{
return m_baseDir() + "/model_input.json";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellIASettings::csvInputFilename() const
{
return m_baseDir() + "/model_input.csv";
}
QStringList RimWellIASettings::commandParameters() const
{
QStringList retlist;
retlist << m_baseDir();
retlist << jsonInputFilename();
retlist << csvInputFilename();
return retlist;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettings::setGeoMechCase( RimGeoMechCase* geomechCase )
{
m_geomechCase = geomechCase;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettings::setOutputBaseDirectory( QString baseDir )
{
m_baseDir = baseDir;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettings::setShowBox( bool show )
{
m_showBox = show;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellIASettings::showBox() const
{
return m_showBox && m_boxValid;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::list<RimParameterGroup*> RimWellIASettings::inputParameterGroups() const
{
std::list<RimParameterGroup*> retlist;
for ( auto& group : m_parameters )
retlist.push_back( group );
return retlist;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::list<RimParameterGroup*> RimWellIASettings::resinsightParameterGroups() const
{
std::list<RimParameterGroup*> retlist;
for ( auto& group : m_parametersRI )
retlist.push_back( group );
return retlist;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettings::resetResInsightParameters()
{
for ( auto& group : m_parametersRI )
{
delete group;
}
m_parametersRI.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettings::updateResInsightParameters()
{
resetResInsightParameters();
RimParameterGroup* wellcoords = new RimParameterGroup();
wellcoords->setName( "well_coordinates" );
wellcoords->setLabel( "Well Coordinates" );
wellcoords->addParameter( "x_well", m_modelbox.center().x() );
wellcoords->addParameter( "y_well", m_modelbox.center().y() );
wellcoords->addParameter( "z_well", m_modelbox.center().z() );
m_parametersRI.push_back( wellcoords );
RimParameterGroup* initcond = new RimParameterGroup();
initcond->setName( "BC_initial_conditions" );
initcond->setLabel( "BC Initial Conditions" );
initcond->addParameter( "analysis_depth", std::abs( m_modelbox.center().z() ) );
m_parametersRI.push_back( initcond );
RimParameterGroup* initialStress = new RimParameterGroup();
initialStress->setName( "initial_stress" );
initialStress->setLabel( "Initial Stress" );
initialStress->setComment(
"SXX is in North direction, SYY is East, SZZ is vertical; PP is the initial pore pressure in the "
"formation, set to 0 for hydrostatic assumption; inclination is 0 for a vertical well" );
cvf::Vec3d position = m_modelbox.center();
RimWellIADataAccess dataAccess( m_geomechCase );
std::vector<QString> nativeKeys{ "S11", "S22", "S33", "S12", "S13", "S23" };
std::vector<QString> paramKeys{ "SXX", "SYY", "SZZ", "SXY", "SXZ", "SYZ" };
for ( size_t i = 0; i < nativeKeys.size(); i++ )
{
double stressValue =
dataAccess.interpolatedResultValue( "ST", nativeKeys[i], RigFemResultPosEnum::RIG_ELEMENT_NODAL, position, 0 );
initialStress->addParameter( paramKeys[i], stressValue );
}
double ppValue = dataAccess.interpolatedResultValue( "POR-Bar", "", RigFemResultPosEnum::RIG_NODAL, position, 0 );
initialStress->addParameter( "PP", ppValue );
auto angles = RigWellPathGeometryTools::calculateAzimuthAndInclinationAtMd( ( m_startMD + m_endMD ) / 2.0,
wellPath()->wellPathGeometry() );
initialStress->addParameter( "azimuth_well", angles.first );
initialStress->addParameter( "inclination_well", angles.second );
m_parametersRI.push_back( initialStress );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettings::addCsvGroup( QString name, QStringList timeSteps, double defaultValue /* = 0.0 */ )
{
RimParameterGroup* group = new RimParameterGroup();
group->setName( name );
const int noParams = timeSteps.size();
for ( int i = 0; i < noParams; i++ )
{
group->addParameter( timeSteps[i], defaultValue );
}
m_csvParameters.push_back( group );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettings::initCsvParameters()
{
m_csvParameters.clear();
QStringList timeSteps = m_geomechCase->timeStepStrings();
addCsvGroup( m_csvGroupNames[(size_t)CSV_GROUPNAME::CASING_PRESSURE], timeSteps );
addCsvGroup( m_csvGroupNames[(size_t)CSV_GROUPNAME::FORMATION_PRESSURE], timeSteps );
addCsvGroup( m_csvGroupNames[(size_t)CSV_GROUPNAME::TEMPERATURE], timeSteps, 70.0 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettings::setDepthInterval( double startMD, double endMD )
{
m_startMD = startMD;
m_endMD = endMD;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimWellIASettings::startMD()
{
return m_startMD;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimWellIASettings::endMD()
{
return m_endMD;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettings::resetModelData()
{
for ( auto& modeldata : m_modelData )
{
delete modeldata;
}
m_modelData.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPath* RimWellIASettings::wellPath() const
{
RimWellPath* wellpath = nullptr;
this->firstAncestorOrThisOfTypeAsserted( wellpath );
return wellpath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettings::generateModelBox()
{
RimWellPath* path = wellPath();
if ( !path ) return;
RigWellPath* wellgeom = path->wellPathGeometry();
if ( !wellgeom ) return;
cvf::Vec3d startPos = wellgeom->interpolatedPointAlongWellPath( m_startMD );
cvf::Vec3d endPos = wellgeom->interpolatedPointAlongWellPath( m_endMD );
m_boxValid = m_modelbox.updateBox( startPos, endPos, m_bufferXY, m_bufferZ );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettings::extractModelData()
{
generateModelBox();
updateResInsightParameters();
resetModelData();
QDateTime startDate = geostaticDate();
int timestep = 0;
auto timeStepStrings = m_geomechCase->timeStepStrings();
for ( auto& date : timeStepDates() )
{
RimWellIAModelData* data = new RimWellIAModelData();
data->setDayOffset( startDate.daysTo( date ) );
for ( auto& group : m_csvParameters )
{
if ( group->name() == m_csvGroupNames[(size_t)CSV_GROUPNAME::CASING_PRESSURE] )
{
data->setCasingPressure( group->parameterValue( timeStepStrings[timestep] ).toDouble() );
}
else if ( group->name() == m_csvGroupNames[(size_t)CSV_GROUPNAME::FORMATION_PRESSURE] )
{
data->setFormationPressure( group->parameterValue( timeStepStrings[timestep] ).toDouble() );
}
else if ( group->name() == m_csvGroupNames[(size_t)CSV_GROUPNAME::TEMPERATURE] )
{
data->setTemperature( group->parameterValue( timeStepStrings[timestep] ).toDouble() );
}
}
const std::vector<cvf::Vec3d> displacements = extractDisplacments( m_modelbox.vertices(), timestep );
for ( size_t i = 0; i < displacements.size(); i++ )
{
data->setDisplacement( (int)i, displacements[i] );
}
m_modelData.push_back( data );
timestep++;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QDateTime> RimWellIASettings::timeStepDates()
{
std::vector<QDateTime> dates = m_geomechCase->timeStepDates();
if ( dates.size() < (size_t)m_geomechCase->timeStepStrings().size() )
dates.insert( dates.begin(), m_geostaticDate );
return dates;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RimWellIASettings::extractDisplacments( std::vector<cvf::Vec3d> corners, int timeStep )
{
RimWellIADataAccess dataAccess( m_geomechCase );
std::vector<cvf::Vec3d> displacements;
for ( auto& pos : corners )
{
double u1 = dataAccess.interpolatedResultValue( "U", "U1", RigFemResultPosEnum::RIG_NODAL, pos, timeStep );
double u2 = dataAccess.interpolatedResultValue( "U", "U2", RigFemResultPosEnum::RIG_NODAL, pos, timeStep );
double u3 = dataAccess.interpolatedResultValue( "U", "U3", RigFemResultPosEnum::RIG_NODAL, pos, timeStep );
displacements.push_back( cvf::Vec3d( u1, u2, u3 ) );
}
return displacements;
}

View File

@ -0,0 +1,145 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimCheckableNamedObject.h"
#include "RimWellIAModelBox.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmObject.h"
#include "cafPdmProxyValueField.h"
#include "cafPdmPtrField.h"
#include "cvfVector3.h"
#include <QDateTime>
#include <QString>
#include <QStringList>
#include <list>
#include <string>
#include <vector>
class RimGeoMechCase;
class RimParameterGroup;
class RimGenericParameter;
class RimWellPath;
class RimWellIAModelData;
class RimWellIASettings : public RimCheckableNamedObject
{
CAF_PDM_HEADER_INIT;
public:
RimWellIASettings();
~RimWellIASettings() override;
bool initSettings( QString& outErrmsg );
void setGeoMechCase( RimGeoMechCase* geomechCase );
RimGeoMechCase* geomechCase() const;
QString geomechCaseFilename() const;
QString geomechCaseName() const;
QDateTime geostaticDate() const;
void setOutputBaseDirectory( QString baseDir );
QString outputBaseDirectory() const;
bool showBox() const;
void setShowBox( bool show );
const std::list<RimParameterGroup*> inputParameterGroups() const;
const std::list<RimParameterGroup*> resinsightParameterGroups() const;
void setDepthInterval( double startMD, double endMD );
double startMD();
double endMD();
QString jsonInputFilename() const;
QString csvInputFilename() const;
QStringList commandParameters() const;
RimWellPath* wellPath() const;
bool modelBoxValid() const;
std::vector<cvf::Vec3d> modelBoxVertices() const;
std::vector<RimWellIAModelData*> modelData() const;
void extractModelData();
void updateVisualization();
protected:
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
caf::PdmFieldHandle* userDescriptionField() override;
QString fullName() const;
private:
std::vector<QDateTime> timeStepDates();
void initCsvParameters();
void updateResInsightParameters();
void generateModelBox();
void resetModelData();
void resetResInsightParameters();
void addCsvGroup( QString name, QStringList timeSteps, double defaultValue = 0.0 );
std::vector<cvf::Vec3d> extractDisplacments( std::vector<cvf::Vec3d> corners, int timeStep );
private:
caf::PdmProxyValueField<QString> m_nameProxy;
caf::PdmPtrField<RimGeoMechCase*> m_geomechCase;
caf::PdmField<QString> m_baseDir;
caf::PdmField<bool> m_showBox;
caf::PdmField<bool> m_boxValid;
caf::PdmField<double> m_startMD;
caf::PdmField<double> m_endMD;
caf::PdmField<double> m_bufferXY;
caf::PdmField<double> m_bufferZ;
caf::PdmField<QDateTime> m_geostaticDate;
caf::PdmChildArrayField<RimParameterGroup*> m_parameters;
std::vector<RimParameterGroup*> m_parametersRI;
caf::PdmChildArrayField<RimParameterGroup*> m_csvParameters;
RimWellIAModelBox m_modelbox;
std::vector<RimWellIAModelData*> m_modelData;
enum class CSV_GROUPNAME
{
FORMATION_PRESSURE = 0,
CASING_PRESSURE = 1,
TEMPERATURE = 2
};
const std::vector<QString> m_csvGroupNames{ "Formation Pressure", "Casing Pressure", "Temperature" };
};

View File

@ -0,0 +1,119 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 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 "RimWellIASettingsCollection.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RimGeoMechCase.h"
#include "RimProject.h"
#include "RimWellIASettings.h"
#include "RimWellPath.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "QFile"
CAF_PDM_SOURCE_INIT( RimWellIASettingsCollection, "RimWellIASettingsCollection" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellIASettingsCollection::RimWellIASettingsCollection()
{
CAF_PDM_InitObject( "Integrity Analysis Models", ":/WellIntAnalysis.png", "", "" );
CAF_PDM_InitFieldNoDefault( &m_wellIASettings, "WellIASettings", "Settings", "", "", "" );
m_wellIASettings.uiCapability()->setUiTreeHidden( true );
setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellIASettingsCollection::~RimWellIASettingsCollection()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellIASettings* RimWellIASettingsCollection::startWellIntegrationAnalysis( QString baseDir,
RimWellPath* wellPath,
double measuredDepth,
RimGeoMechCase* theCase,
QString& outErrmsg )
{
RimWellIASettings* modelSettings = new RimWellIASettings();
modelSettings->setGeoMechCase( theCase );
double depthSize = 50;
if ( theCase ) depthSize = theCase->characteristicCellSize();
modelSettings->setDepthInterval( measuredDepth, measuredDepth + depthSize );
modelSettings->setOutputBaseDirectory( baseDir );
QString errmsg;
if ( !modelSettings->initSettings( errmsg ) )
{
delete modelSettings;
outErrmsg = "Unable to load default parameters from the WIA default parameter XML file:\n" + errmsg;
return nullptr;
}
m_wellIASettings.push_back( modelSettings );
return modelSettings;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimWellIASettings*> RimWellIASettingsCollection::settings() const
{
return m_wellIASettings.childObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellIASettingsCollection::isEnabled() const
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellIASettingsCollection::hasSettings() const
{
return m_wellIASettings.size() > 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellIASettingsCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects )
{
RimWellPath* wellPath;
this->firstAncestorOrThisOfType( wellPath );
if ( wellPath ) wellPath->updateConnectedEditors();
RiaApplication::instance()->project()->scheduleCreateDisplayModelAndRedrawAllViews();
}

View File

@ -0,0 +1,55 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmObject.h"
#include <QString>
class RimWellIASettings;
class RimWellPath;
class RimGeoMechCase;
class RimWellIASettingsCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimWellIASettingsCollection();
~RimWellIASettingsCollection() override;
std::vector<RimWellIASettings*> settings() const;
bool isEnabled() const;
bool hasSettings() const;
RimWellIASettings* startWellIntegrationAnalysis( QString baseDir,
RimWellPath* wellPath,
double measuredDepth,
RimGeoMechCase* theCase,
QString& outErrmsg );
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
private:
caf::PdmChildArrayField<RimWellIASettings*> m_wellIASettings;
};

View File

@ -42,6 +42,7 @@
#include "RimProject.h"
#include "RimStimPlanModelCollection.h"
#include "RimTools.h"
#include "RimWellIASettingsCollection.h"
#include "RimWellLogFile.h"
#include "RimWellLogFileChannel.h"
#include "RimWellLogPlotCollection.h"
@ -137,6 +138,12 @@ RimWellPath::RimWellPath()
CAF_PDM_InitFieldNoDefault( &m_wellPathTieIn, "WellPathTieIn", "well Path Tie-In", "", "", "" );
m_wellPathTieIn = new RimWellPathTieIn;
m_wellPathTieIn->connectWellPaths( nullptr, this, 0.0 );
CAF_PDM_InitFieldNoDefault( &m_wellIASettingsCollection, "WellIASettings", "Integrity Analysis Settings", "", "", "" );
m_wellIASettingsCollection = new RimWellIASettingsCollection();
m_wellIASettingsCollection->uiCapability()->setUiTreeHidden( true );
this->setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
@ -610,6 +617,14 @@ const RimWellPathAttributeCollection* RimWellPath::attributeCollection() const
return m_wellPathAttributes;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellIASettingsCollection* RimWellPath::wellIASettingsCollection()
{
return m_wellIASettingsCollection;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -714,6 +729,11 @@ void RimWellPath::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering,
{
uiTreeOrdering.add( &m_wellLogFiles );
if ( m_wellIASettingsCollection()->isEnabled() && m_wellIASettingsCollection()->hasSettings() )
{
uiTreeOrdering.add( m_wellIASettingsCollection() );
}
if ( m_completionSettings() && !allCompletionsRecursively().empty() )
{
uiTreeOrdering.add( m_completionSettings() );

View File

@ -59,6 +59,7 @@ class Rim3dWellLogCurve;
class Rim3dWellLogCurveCollection;
class RimWellPathTieIn;
class RimMswCompletionParameters;
class RimWellIASettingsCollection;
//==================================================================================================
///
@ -136,6 +137,7 @@ public:
const RimStimPlanModelCollection* stimPlanModelCollection() const;
RimWellPathAttributeCollection* attributeCollection();
const RimWellPathAttributeCollection* attributeCollection() const;
RimWellIASettingsCollection* wellIASettingsCollection();
bool showWellPathLabel() const;
bool showWellPath() const;
@ -210,6 +212,7 @@ private:
caf::PdmChildField<RimWellPathCompletionSettings*> m_completionSettings;
caf::PdmChildField<RimWellPathCompletions*> m_completions;
caf::PdmChildField<RimWellPathAttributeCollection*> m_wellPathAttributes;
caf::PdmChildField<RimWellIASettingsCollection*> m_wellIASettingsCollection;
caf::PdmChildField<RimWellPathTieIn*> m_wellPathTieIn;

View File

@ -67,6 +67,7 @@
#include "RimSurfaceInView.h"
#include "RimTextAnnotation.h"
#include "RimViewController.h"
#include "RimWellIASettingsCollection.h"
#include "RimWellPath.h"
#include "Riu3dSelectionManager.h"
@ -538,6 +539,13 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
menuBuilder.subMenuEnd();
menuBuilder.addSeparator();
if ( wellPath->wellIASettingsCollection()->isEnabled() )
{
menuBuilder << "RicNewWellIntegrityAnalysisFeature";
menuBuilder.addSeparator();
}
menuBuilder.subMenuStart( "Create Completions", QIcon( ":/FishBoneGroup16x16.png" ) );
menuBuilder << "RicNewPerforationIntervalAtMeasuredDepthFeature";