Skip to content

Commit

Permalink
Import faults when using omp common file reader, too
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjenssen committed Feb 19, 2024
1 parent 8fe8242 commit df85be8
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 47 deletions.
38 changes: 2 additions & 36 deletions ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,13 @@ bool RifReaderEclipseOutput::open( const QString& fileName, RigEclipseCaseData*

if ( !RifEclipseOutputFileTools::findSiblingFilesWithSameBaseName( fileName, &fileSet ) ) return false;

m_fileName = fileName;
m_fileName = fileName;
m_filesWithSameBaseName = fileSet;
}

ecl_grid_type* mainEclGrid = nullptr;
{
auto task = progress.task( "Open Init File and Load Main Grid", 19 );
// Keep the set of files of interest
m_filesWithSameBaseName = fileSet;

openInitFile();

Expand Down Expand Up @@ -608,39 +607,6 @@ const size_t* RifReaderEclipseOutput::eclipseCellIndexMapping()
return cellMappingECLRi;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseOutput::importFaults( const QStringList& fileSet, cvf::Collection<RigFault>* faults )
{
if ( !filenamesWithFaults().empty() )
{
for ( size_t i = 0; i < filenamesWithFaults().size(); i++ )
{
QString faultFilename = filenamesWithFaults()[i];

RifEclipseInputFileTools::parseAndReadFaults( faultFilename, faults );
}
}
else
{
foreach ( QString fname, fileSet )
{
if ( fname.endsWith( ".DATA" ) )
{
std::vector<QString> filenamesWithFaults;
RifEclipseInputFileTools::readFaultsInGridSection( fname, faults, &filenamesWithFaults, faultIncludeFileAbsolutePathPrefix() );

std::sort( filenamesWithFaults.begin(), filenamesWithFaults.end() );
std::vector<QString>::iterator last = std::unique( filenamesWithFaults.begin(), filenamesWithFaults.end() );
filenamesWithFaults.erase( last, filenamesWithFaults.end() );

setFilenamesWithFaults( filenamesWithFaults );
}
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions ApplicationLibCode/FileInterface/RifReaderEclipseOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ class RifReaderEclipseOutput : public RifReaderInterface
const well_segment_type* segment,
const char* wellName );

void importFaults( const QStringList& fileSet, cvf::Collection<RigFault>* faults );

void openInitFile();

void extractResultValuesBasedOnPorosityModel( RiaDefines::PorosityModelType matrixOrFracture,
Expand Down
34 changes: 34 additions & 0 deletions ApplicationLibCode/FileInterface/RifReaderInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "RiaPreferences.h"

#include "RifEclipseInputFileTools.h"
#include "RifReaderSettings.h"

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -144,3 +145,36 @@ void RifReaderInterface::setReaderSettings( std::shared_ptr<RifReaderSettings> r
{
m_readerSettings = readerSettings;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderInterface::importFaults( const QStringList& fileSet, cvf::Collection<RigFault>* faults )
{
if ( !filenamesWithFaults().empty() )
{
for ( size_t i = 0; i < filenamesWithFaults().size(); i++ )
{
QString faultFilename = filenamesWithFaults()[i];

RifEclipseInputFileTools::parseAndReadFaults( faultFilename, faults );
}
}
else
{
foreach ( QString fname, fileSet )
{
if ( fname.endsWith( ".DATA" ) )
{
std::vector<QString> filenamesWithFaults;
RifEclipseInputFileTools::readFaultsInGridSection( fname, faults, &filenamesWithFaults, faultIncludeFileAbsolutePathPrefix() );

std::sort( filenamesWithFaults.begin(), filenamesWithFaults.end() );
std::vector<QString>::iterator last = std::unique( filenamesWithFaults.begin(), filenamesWithFaults.end() );
filenamesWithFaults.erase( last, filenamesWithFaults.end() );

setFilenamesWithFaults( filenamesWithFaults );
}
}
}
}
3 changes: 3 additions & 0 deletions ApplicationLibCode/FileInterface/RifReaderInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "RiaDefines.h"
#include "RiaPorosityModel.h"

#include "cvfCollection.h"
#include "cvfObject.h"

#include "cafPdmPointer.h"
Expand All @@ -36,6 +37,7 @@

class RigEclipseCaseData;
class RifReaderSettings;
class RigFault;

//==================================================================================================
//
Expand Down Expand Up @@ -77,6 +79,7 @@ class RifReaderInterface : public cvf::Object
protected:
bool isTimeStepIncludedByFilter( size_t timeStepIndex ) const;
size_t timeStepIndexOnFile( size_t timeStepIndex ) const;
void importFaults( const QStringList& fileSet, cvf::Collection<RigFault>* faults );

private:
const RifReaderSettings* readerSettings() const;
Expand Down
23 changes: 22 additions & 1 deletion ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "RigSimWellData.h"
#include "RigWellResultFrame.h"

#include "cafProgressInfo.h"

#include "opm/input/eclipse/Deck/Deck.hpp"
#include "opm/input/eclipse/EclipseState/Runspec.hpp"
#include "opm/input/eclipse/Parser/Parser.hpp"
Expand Down Expand Up @@ -65,6 +67,8 @@ RifReaderOpmCommon::~RifReaderOpmCommon()
//--------------------------------------------------------------------------------------------------
bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* eclipseCase )
{
caf::ProgressInfo progress( 100, "Reading Grid" );

QStringList fileSet;
if ( !RifEclipseOutputFileTools::findSiblingFilesWithSameBaseName( fileName, &fileSet ) ) return false;

Expand All @@ -79,7 +83,24 @@ bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* ecli
return false;
}

buildMetaData( eclipseCase );
{
auto task = progress.task( "Reading faults", 25 );

if ( isFaultImportEnabled() )
{
cvf::Collection<RigFault> faults;

importFaults( fileSet, &faults );

RigMainGrid* mainGrid = eclipseCase->mainGrid();
mainGrid->setFaults( faults );
}
}

{
auto task = progress.task( "Reading Results Meta data", 50 );
buildMetaData( eclipseCase );
}

return true;
}
Expand Down
12 changes: 7 additions & 5 deletions ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ RimEclipseCase::RimEclipseCase()
CAF_PDM_InitField( &m_flipXAxis, "FlipXAxis", false, "Flip X Axis" );
CAF_PDM_InitField( &m_flipYAxis, "FlipYAxis", false, "Flip Y Axis" );

CAF_PDM_InitFieldNoDefault( &m_filesContainingFaults_OBSOLETE, "CachedFileNamesContainingFaults", "" );
m_filesContainingFaults_OBSOLETE.uiCapability()->setUiHidden( true );
m_filesContainingFaults_OBSOLETE.xmlCapability()->disableIO();
CAF_PDM_InitFieldNoDefault( &m_filesContainingFaults, "CachedFileNamesContainingFaults", "" );
m_filesContainingFaults.uiCapability()->setUiHidden( true );
// Caching of file names causes issues when using the project file as template, do not save to disk
// https://github.com/OPM/ResInsight/issues/7308
m_filesContainingFaults.xmlCapability()->disableIO();

CAF_PDM_InitFieldNoDefault( &m_contourMapCollection, "ContourMaps", "2d Contour Maps" );
m_contourMapCollection = new RimEclipseContourMapViewCollection;
Expand Down Expand Up @@ -927,7 +929,7 @@ std::vector<QString> RimEclipseCase::filesContainingFaults() const
{
std::vector<QString> stdPathList;

for ( auto& filePath : m_filesContainingFaults_OBSOLETE() )
for ( auto& filePath : m_filesContainingFaults() )
{
stdPathList.push_back( filePath.path() );
}
Expand All @@ -946,7 +948,7 @@ void RimEclipseCase::setFilesContainingFaults( const std::vector<QString>& pathS
filePaths.push_back( pathString );
}

m_filesContainingFaults_OBSOLETE = filePaths;
m_filesContainingFaults = filePaths;
}

//--------------------------------------------------------------------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions ApplicationLibCode/ProjectDataModel/RimEclipseCase.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,5 @@ class RimEclipseCase : public RimCase
caf::PdmChildField<RimReservoirCellResultsStorage*> m_matrixModelResults;
caf::PdmChildField<RimReservoirCellResultsStorage*> m_fractureModelResults;

// To be removed as the caching of file names causes issues when using the project file as template
// https://github.com/OPM/ResInsight/issues/7308
caf::PdmField<std::vector<caf::FilePath>> m_filesContainingFaults_OBSOLETE;
caf::PdmField<std::vector<caf::FilePath>> m_filesContainingFaults;
};

0 comments on commit df85be8

Please sign in to comment.