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
49 changed files with 2778 additions and 30 deletions

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(){};
};