2016-04-12 04:32:28 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2016-04-12 04:32:28 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2016-04-12 04:32:28 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2016-04-12 04:32:28 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RifEclipseSummaryTools.h"
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RiaFilePathTools.h"
|
|
|
|
#include "RiaStringEncodingTools.h"
|
2017-11-24 08:17:20 -06:00
|
|
|
#include "RiaSummaryCurveAnalyzer.h"
|
2016-04-12 04:32:28 -05:00
|
|
|
#include "RifReaderEclipseSummary.h"
|
|
|
|
|
2016-06-09 03:55:48 -05:00
|
|
|
#include "cafAppEnum.h"
|
2016-04-12 04:32:28 -05:00
|
|
|
|
2017-11-24 08:17:20 -06:00
|
|
|
#include "ert/ecl/ecl_util.h"
|
2016-04-12 04:32:28 -05:00
|
|
|
|
2018-04-13 04:11:05 -05:00
|
|
|
#include <QDir>
|
2018-02-02 07:17:10 -06:00
|
|
|
#include <QString>
|
|
|
|
#include <QStringList>
|
|
|
|
|
2017-11-24 08:17:20 -06:00
|
|
|
#include <iostream>
|
2016-04-12 04:32:28 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-04-12 04:32:28 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RifEclipseSummaryTools::findSummaryHeaderFile( const QString& inputFile, QString* headerFile, bool* isFormatted )
|
2016-04-12 04:32:28 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
findSummaryHeaderFileInfo( inputFile, headerFile, nullptr, nullptr, isFormatted );
|
2016-04-12 04:32:28 -05:00
|
|
|
}
|
|
|
|
|
2016-05-31 06:42:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-05-31 06:42:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RifEclipseSummaryTools::findSummaryFiles( const QString& inputFile, QString* headerFile, QStringList* dataFiles )
|
2016-05-31 06:42:27 -05:00
|
|
|
{
|
|
|
|
dataFiles->clear();
|
|
|
|
headerFile->clear();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
char* myPath = nullptr;
|
|
|
|
char* myBase = nullptr;
|
2018-02-18 11:56:43 -06:00
|
|
|
char* myExtention = nullptr;
|
2016-05-31 06:42:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
util_alloc_file_components( RiaStringEncodingTools::toNativeEncoded( inputFile ).data(),
|
|
|
|
&myPath,
|
|
|
|
&myBase,
|
|
|
|
&myExtention );
|
2016-05-31 06:42:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QString path;
|
|
|
|
if ( myPath ) path = RiaStringEncodingTools::fromNativeEncoded( myPath );
|
|
|
|
QString base;
|
|
|
|
if ( myBase ) base = RiaStringEncodingTools::fromNativeEncoded( myBase );
|
|
|
|
std::string extention;
|
|
|
|
if ( myExtention ) extention = myExtention;
|
2016-05-31 06:42:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( path.isEmpty() || base.isEmpty() ) return;
|
2016-05-31 06:42:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
char* myHeaderFile = nullptr;
|
2016-05-31 06:42:27 -05:00
|
|
|
stringlist_type* summary_file_list = stringlist_alloc_new();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
ecl_util_alloc_summary_files( RiaStringEncodingTools::toNativeEncoded( path ).data(),
|
|
|
|
RiaStringEncodingTools::toNativeEncoded( base ).data(),
|
|
|
|
extention.data(),
|
|
|
|
&myHeaderFile,
|
|
|
|
summary_file_list );
|
|
|
|
if ( myHeaderFile )
|
2016-06-29 03:43:36 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
( *headerFile ) = RiaStringEncodingTools::fromNativeEncoded( myHeaderFile );
|
|
|
|
free( myHeaderFile );
|
2016-06-29 03:43:36 -05:00
|
|
|
}
|
2016-05-31 06:42:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( stringlist_get_size( summary_file_list ) > 0 )
|
2016-05-31 06:42:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( int i = 0; i < stringlist_get_size( summary_file_list ); i++ )
|
2016-05-31 06:42:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
dataFiles->push_back( RiaStringEncodingTools::fromNativeEncoded( stringlist_iget( summary_file_list, i ) ) );
|
2016-05-31 06:42:27 -05:00
|
|
|
}
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
stringlist_free( summary_file_list );
|
2016-05-31 06:42:27 -05:00
|
|
|
}
|
|
|
|
|
2018-04-13 04:11:05 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-04-13 04:11:05 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
QString RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile( const QString& summaryHeaderFile )
|
2018-04-13 04:11:05 -05:00
|
|
|
{
|
|
|
|
char* myPath = nullptr;
|
|
|
|
char* myBase = nullptr;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
util_alloc_file_components( RiaStringEncodingTools::toNativeEncoded( QDir::toNativeSeparators( summaryHeaderFile ) )
|
|
|
|
.data(),
|
|
|
|
&myPath,
|
|
|
|
&myBase,
|
|
|
|
nullptr );
|
2018-04-13 04:11:05 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
char* caseFile = ecl_util_alloc_exfilename( myPath, myBase, ECL_EGRID_FILE, true, -1 );
|
|
|
|
if ( !caseFile )
|
2018-04-13 04:11:05 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
caseFile = ecl_util_alloc_exfilename( myPath, myBase, ECL_EGRID_FILE, false, -1 );
|
2018-04-13 04:11:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
QString gridCaseFile;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( caseFile ) gridCaseFile = caseFile;
|
2018-04-13 04:11:05 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
free( caseFile );
|
|
|
|
free( myBase );
|
|
|
|
free( myPath );
|
2018-04-13 04:11:05 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
return RiaFilePathTools::toInternalSeparator( gridCaseFile );
|
2018-04-13 04:11:05 -05:00
|
|
|
}
|
|
|
|
|
2016-04-12 04:32:28 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-04-12 04:32:28 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RifEclipseSummaryTools::dumpMetaData( RifSummaryReaderInterface* readerEclipseSummary )
|
2016-04-12 04:32:28 -05:00
|
|
|
{
|
2018-06-25 08:14:47 -05:00
|
|
|
std::set<RifEclipseSummaryAddress> addresses = readerEclipseSummary->allResultAddresses();
|
2016-04-12 04:32:28 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( int category = 0; category < RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR; category++ )
|
2016-04-12 04:32:28 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RifEclipseSummaryAddress::SummaryVarCategory categoryEnum = RifEclipseSummaryAddress::SummaryVarCategory(
|
|
|
|
category );
|
2016-05-04 07:11:04 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<RifEclipseSummaryAddress> catAddresses = RiaSummaryCurveAnalyzer::addressesForCategory( addresses,
|
|
|
|
categoryEnum );
|
2016-04-12 04:32:28 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( catAddresses.size() > 0 )
|
2016-04-12 04:32:28 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
std::cout << caf::AppEnum<RifEclipseSummaryAddress::SummaryVarCategory>::uiText( categoryEnum ).toStdString()
|
|
|
|
<< " count : " << catAddresses.size() << std::endl;
|
2016-04-12 04:32:28 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( size_t i = 0; i < catAddresses.size(); i++ )
|
2016-05-04 07:11:04 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
std::cout << catAddresses[i].quantityName() << " " << catAddresses[i].regionNumber() << " "
|
|
|
|
<< catAddresses[i].regionNumber2() << " " << catAddresses[i].wellGroupName() << " "
|
|
|
|
<< catAddresses[i].wellName() << " " << catAddresses[i].wellSegmentNumber() << " "
|
|
|
|
<< catAddresses[i].lgrName() << " " << catAddresses[i].cellI() << " "
|
|
|
|
<< catAddresses[i].cellJ() << " " << catAddresses[i].cellK() << std::endl;
|
2016-05-04 07:11:04 -05:00
|
|
|
}
|
2016-04-12 04:32:28 -05:00
|
|
|
|
2016-05-04 07:11:04 -05:00
|
|
|
std::cout << std::endl;
|
2016-04-12 04:32:28 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-04-12 04:32:28 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-04 07:35:41 -06:00
|
|
|
void RifEclipseSummaryTools::findSummaryHeaderFileInfo( const QString& inputFile,
|
|
|
|
QString* headerFile,
|
|
|
|
QString* path,
|
|
|
|
QString* base,
|
|
|
|
bool* isFormatted )
|
2016-04-12 04:32:28 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
char* myPath = nullptr;
|
|
|
|
char* myBase = nullptr;
|
|
|
|
bool formattedFile = true;
|
2016-04-12 04:32:28 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
util_alloc_file_components( RiaStringEncodingTools::toNativeEncoded( QDir::toNativeSeparators( inputFile ) ).data(),
|
|
|
|
&myPath,
|
|
|
|
&myBase,
|
|
|
|
nullptr );
|
2016-04-12 04:32:28 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
char* myHeaderFile = ecl_util_alloc_exfilename( myPath, myBase, ECL_SUMMARY_HEADER_FILE, true, -1 );
|
|
|
|
if ( !myHeaderFile )
|
2016-04-12 04:32:28 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
myHeaderFile = ecl_util_alloc_exfilename( myPath, myBase, ECL_SUMMARY_HEADER_FILE, false, -1 );
|
|
|
|
if ( myHeaderFile )
|
2016-04-12 04:32:28 -05:00
|
|
|
{
|
|
|
|
formattedFile = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( myHeaderFile && headerFile ) *headerFile = RiaFilePathTools::toInternalSeparator( myHeaderFile );
|
|
|
|
if ( myPath && path ) *path = RiaFilePathTools::toInternalSeparator( myPath );
|
|
|
|
if ( myBase && base ) *base = RiaFilePathTools::toInternalSeparator( myBase );
|
|
|
|
if ( isFormatted ) *isFormatted = formattedFile;
|
2016-04-12 04:32:28 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
free( myHeaderFile );
|
|
|
|
free( myBase );
|
|
|
|
free( myPath );
|
2016-04-12 04:32:28 -05:00
|
|
|
}
|