Merge pull request #5439 from OPM/nnc-improvements

Improve NNC results for complete NNC geometry
This commit is contained in:
Magne Sjaastad 2020-01-30 13:34:28 +01:00 committed by GitHub
commit d8ef29a3c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 132 additions and 46 deletions

View File

@ -25,7 +25,10 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const QChar RiaFilePathTools::SEPARATOR = '/';
const QChar RiaFilePathTools::separator()
{
return '/';
}
//--------------------------------------------------------------------------------------------------
///
@ -42,7 +45,7 @@ QString RiaFilePathTools::toInternalSeparator( const QString& path )
// On other systems (i.e. Windows) -> Convert to internal separator (/)
QString output = path;
return output.replace( QString( "\\" ), SEPARATOR );
return output.replace( QString( "\\" ), separator() );
}
//--------------------------------------------------------------------------------------------------
@ -50,9 +53,9 @@ QString RiaFilePathTools::toInternalSeparator( const QString& path )
//--------------------------------------------------------------------------------------------------
QString& RiaFilePathTools::appendSeparatorIfNo( QString& path )
{
if ( !path.endsWith( SEPARATOR ) )
if ( !path.endsWith( separator() ) )
{
path.append( SEPARATOR );
path.append( separator() );
}
return path;
}
@ -67,7 +70,7 @@ QString RiaFilePathTools::relativePath( const QString& rootDir, const QString& d
QString relPath = dir;
relPath.remove( 0, rootDir.size() );
if ( relPath.startsWith( SEPARATOR ) ) relPath.remove( 0, 1 );
if ( relPath.startsWith( separator() ) ) relPath.remove( 0, 1 );
return appendSeparatorIfNo( relPath );
}
else
@ -102,7 +105,7 @@ QString RiaFilePathTools::canonicalPath( const QString& path )
std::pair<QString, QString> RiaFilePathTools::toFolderAndFileName( const QString& absFileName )
{
auto absFN = toInternalSeparator( absFileName );
int lastSep = absFN.lastIndexOf( SEPARATOR );
int lastSep = absFN.lastIndexOf( separator() );
if ( lastSep > 0 )
{
return std::make_pair( absFN.left( lastSep ), absFN.mid( lastSep + 1 ) );
@ -123,7 +126,7 @@ QString RiaFilePathTools::removeDuplicatePathSeparators( const QString& path )
do
{
len = correctedPath.size();
correctedPath.replace( QString( "%1%1" ).arg( SEPARATOR ), SEPARATOR );
correctedPath.replace( QString( "%1%1" ).arg( separator() ), separator() );
} while ( correctedPath.size() != len );
return correctedPath;
@ -134,7 +137,7 @@ QString RiaFilePathTools::removeDuplicatePathSeparators( const QString& path )
//--------------------------------------------------------------------------------------------------
QString RiaFilePathTools::rootSearchPathFromSearchFilter( const QString& searchFilter )
{
QStringList pathPartList = searchFilter.split( SEPARATOR );
QStringList pathPartList = searchFilter.split( separator() );
QStringList::iterator pathPartIt = pathPartList.begin();
@ -156,5 +159,5 @@ QString RiaFilePathTools::rootSearchPathFromSearchFilter( const QString& searchF
pathPartList.erase( pathPartIt, pathPartList.end() );
return pathPartList.join( SEPARATOR );
return pathPartList.join( separator() );
}

View File

@ -32,8 +32,7 @@
class RiaFilePathTools
{
public:
static const QChar SEPARATOR;
static const QChar separator();
static QString toInternalSeparator( const QString& path );
static QString& appendSeparatorIfNo( QString& path );
static QString relativePath( const QString& rootDir, const QString& dir );

View File

@ -46,11 +46,6 @@
#define FIND_BUTTON_FIND_TEXT "Find"
#define FILES_FOUND_TEXT "Files Found"
//--------------------------------------------------------------------------------------------------
/// Internal variables
//--------------------------------------------------------------------------------------------------
static const QChar SEPARATOR = RiaFilePathTools::SEPARATOR;
//--------------------------------------------------------------------------------------------------
/// Internal functions
//--------------------------------------------------------------------------------------------------
@ -250,7 +245,7 @@ QString RicRecursiveFileSearchDialog::pathFilterWithoutStartSeparator() const
QString rootDir = RiaFilePathTools::rootSearchPathFromSearchFilter( pathFilter );
pathFilter.remove( 0, rootDir.size() );
if ( pathFilter.startsWith( SEPARATOR ) ) pathFilter.remove( 0, 1 );
if ( pathFilter.startsWith( RiaFilePathTools::separator() ) ) pathFilter.remove( 0, 1 );
return pathFilter;
}
@ -379,7 +374,7 @@ QStringList RicRecursiveFileSearchDialog::findMatchingFiles()
QString pathFilter = this->pathFilterWithoutStartSeparator();
QString rootDir = this->rootDirWithEndSeparator();
if ( rootDir.size() > 1 && rootDir.endsWith( SEPARATOR ) ) rootDir.chop( 1 );
if ( rootDir.size() > 1 && rootDir.endsWith( RiaFilePathTools::separator() ) ) rootDir.chop( 1 );
buildDirectoryListRecursiveSimple( rootDir, pathFilter, &dirs );
@ -411,7 +406,7 @@ void RicRecursiveFileSearchDialog::buildDirectoryListRecursiveSimple( const QStr
return;
}
QStringList pathFilterPartList = pathFilter.split( SEPARATOR );
QStringList pathFilterPartList = pathFilter.split( RiaFilePathTools::separator() );
QDir qdir( currDir, pathFilterPartList[0], QDir::NoSort, QDir::Dirs | QDir::NoDotAndDotDot );
QStringList subDirs = qdir.entryList();
@ -433,7 +428,7 @@ void RicRecursiveFileSearchDialog::buildDirectoryListRecursiveSimple( const QStr
{
auto pf = pathFilterPartList;
pf.removeFirst();
nextPathFilter = pf.join( SEPARATOR );
nextPathFilter = pf.join( RiaFilePathTools::separator() );
}
buildDirectoryListRecursiveSimple( fullPath, nextPathFilter, accumulatedDirs );
@ -498,7 +493,7 @@ QStringList RicRecursiveFileSearchDialog::createFileNameFilterList()
void RicRecursiveFileSearchDialog::updateEffectiveFilter()
{
QString pathFilterText = pathFilterWithoutStartSeparator();
if ( pathFilterText == "*" || pathFilterText.endsWith( QString( SEPARATOR ) + "*" ) )
if ( pathFilterText == "*" || pathFilterText.endsWith( QString( RiaFilePathTools::separator() ) + "*" ) )
{
pathFilterText.chop( 1 );
pathFilterText = pathFilterText + "...";
@ -789,7 +784,7 @@ QStringList RicRecursiveFileSearchDialog::buildDirectoryListRecursive( const QSt
QString pathFilter = this->pathFilterWithoutStartSeparator();
if ( !pathFilter.startsWith( "*" ) )
{
int wildcardIndex = pathFilter.indexOf( QRegExp( QString( "[*%1]" ).arg( SEPARATOR ) ) );
int wildcardIndex = pathFilter.indexOf( QRegExp( QString( "[*%1]" ).arg( RiaFilePathTools::separator() ) ) );
if ( wildcardIndex >= 0 )
{
currPathFilter = pathFilter.left( wildcardIndex + 1 );
@ -826,7 +821,9 @@ QStringList RicRecursiveFileSearchDialog::buildDirectoryListRecursive( const QSt
bool RicRecursiveFileSearchDialog::pathFilterMatch( const QString& pathFilter, const QString& relPath )
{
QString pattern = pathFilter;
if ( relPath.endsWith( SEPARATOR ) && !pathFilter.endsWith( SEPARATOR ) ) pattern += SEPARATOR;
if ( relPath.endsWith( RiaFilePathTools::separator() ) && !pathFilter.endsWith( RiaFilePathTools::separator() ) )
pattern += RiaFilePathTools::separator();
QRegExp regexp( pattern, Qt::CaseInsensitive, QRegExp::Wildcard );
return regexp.exactMatch( relPath );
}

View File

@ -155,7 +155,7 @@ void RivReservoirFaultsPartMgr::appendPartsToModel( cvf::ModelBasicList* model )
if ( faultCollection->showNNCs() )
{
bool showNncs = true;
bool showAllenNncGeometry = false;
bool showCompleteNncGeo = false;
if ( faultCollection->hideNncsWhenNoResultIsAvailable() )
{
@ -171,7 +171,23 @@ void RivReservoirFaultsPartMgr::appendPartsToModel( cvf::ModelBasicList* model )
if ( eclipseResultAddress.m_resultCatType == RiaDefines::ALLEN_DIAGRAMS )
{
showAllenNncGeometry = true;
showCompleteNncGeo = true;
}
{
QStringList stringsToMatch{RiaDefines::combinedRiTranResultName(),
RiaDefines::combinedRiMultResultName(),
RiaDefines::combinedRiAreaNormTranResultName(),
RiaDefines::combinedTransmissibilityResultName(),
RiaDefines::combinedMultResultName()};
for ( const auto& s : stringsToMatch )
{
if ( eclipseResultAddress.m_resultName.contains( s, Qt::CaseInsensitive ) )
{
showCompleteNncGeo = true;
}
}
}
RigMainGrid* mainGrid = m_reservoirView->mainGrid();
@ -183,7 +199,7 @@ void RivReservoirFaultsPartMgr::appendPartsToModel( cvf::ModelBasicList* model )
if ( showNncs )
{
if ( showAllenNncGeometry )
if ( showCompleteNncGeo )
{
rivFaultPart->appendCompleteNNCFacesToModel( &parts );
}

View File

@ -22,6 +22,7 @@
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimFaultInViewCollection.h"
#include "RiuMainWindow.h"
@ -121,6 +122,13 @@ void RimEclipseFaultColors::defineUiOrdering( QString uiConfigName, caf::PdmUiOr
{
caf::PdmUiGroup* group1 = uiOrdering.addNewGroup( "Result" );
m_customFaultResultColors->uiOrdering( uiConfigName, *group1 );
RimEclipseView* eclipseView = nullptr;
this->firstAncestorOfType( eclipseView );
if ( eclipseView )
{
eclipseView->faultCollection()->uiOrderingFaults( uiConfigName, uiOrdering );
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -1100,6 +1100,7 @@ QString RimEclipseView::createAutoName() const
void RimEclipseView::onUpdateDisplayModelVisibility()
{
faultCollection()->updateConnectedEditors();
m_faultResultSettings->updateConnectedEditors();
// This is required to update the read-only state of simulation wells
// when a range filter is manipulated and visible simulation wells might change

View File

@ -348,7 +348,7 @@ bool RimFaultInViewCollection::isGridVisualizationMode() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFaultInViewCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
void RimFaultInViewCollection::uiOrderingFaults( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
bool isGridVizMode = isGridVisualizationMode();
@ -356,6 +356,23 @@ void RimFaultInViewCollection::defineUiOrdering( QString uiConfigName, caf::PdmU
showFaultFaces.uiCapability()->setUiReadOnly( isGridVizMode );
showOppositeFaultFaces.uiCapability()->setUiReadOnly( isGridVizMode );
caf::PdmUiGroup* ffviz = uiOrdering.addNewGroup( "Fault Face Visibility" );
ffviz->setCollapsedByDefault( true );
ffviz->add( &showFaultFaces );
ffviz->add( &showOppositeFaultFaces );
ffviz->add( &faultResult );
caf::PdmUiGroup* nncViz = uiOrdering.addNewGroup( "NNC Visibility" );
nncViz->setCollapsedByDefault( true );
nncViz->add( &showNNCs );
nncViz->add( &hideNncsWhenNoResultIsAvailable );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFaultInViewCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
caf::PdmUiGroup* labs = uiOrdering.addNewGroup( "Fault Labels" );
labs->add( &showFaultLabel );
labs->add( &faultLabelColor );
@ -363,14 +380,7 @@ void RimFaultInViewCollection::defineUiOrdering( QString uiConfigName, caf::PdmU
caf::PdmUiGroup* adv = uiOrdering.addNewGroup( "Fault Options" );
adv->add( &m_showFaultsOutsideFilters );
caf::PdmUiGroup* ffviz = uiOrdering.addNewGroup( "Fault Face Visibility" );
ffviz->add( &showFaultFaces );
ffviz->add( &showOppositeFaultFaces );
ffviz->add( &faultResult );
caf::PdmUiGroup* nncViz = uiOrdering.addNewGroup( "NNC Visibility" );
nncViz->add( &showNNCs );
nncViz->add( &hideNncsWhenNoResultIsAvailable );
uiOrderingFaults( uiConfigName, uiOrdering );
}
//--------------------------------------------------------------------------------------------------

View File

@ -79,6 +79,8 @@ public:
caf::PdmChildField<RimNoCommonAreaNncCollection*> noCommonAreaNnncCollection;
void uiOrderingFaults( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,

View File

@ -2348,12 +2348,13 @@ double riMult( double transResults, double riTransResults )
{
if ( transResults == HUGE_VAL || riTransResults == HUGE_VAL ) return HUGE_VAL;
// To make 0.0 values give 1.0 in mult value
if ( cvf::Math::abs( riTransResults ) < 1e-12 )
const double epsilon = 1e-9;
if ( cvf::Math::abs( riTransResults ) < epsilon )
{
if ( cvf::Math::abs( transResults ) < 1e-12 )
if ( cvf::Math::abs( transResults ) < epsilon )
{
return 1.0;
return 0.0;
}
return HUGE_VAL;

View File

@ -83,7 +83,21 @@ void RigNNCData::computeCompleteSetOfNncs( const RigMainGrid* mainGrid )
std::vector<RigConnection> otherConnections = RigCellFaceGeometryTools::computeOtherNncs( mainGrid, m_connections );
if ( !otherConnections.empty() )
{
m_connections.insert( m_connections.end(), otherConnections.begin(), otherConnections.end() );
// Transmissibility values from Eclipse has been read into propertyNameCombTrans in
// RifReaderEclipseOutput::transferStaticNNCData(). Initialize computed NNCs with zero transmissibility
auto it = m_connectionResults.find( RiaDefines::propertyNameCombTrans() );
if ( it != m_connectionResults.end() )
{
if ( !it->second.empty() )
{
it->second[0].resize( m_connections.size(), 0.0 );
}
}
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -116,6 +116,12 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
}
}
}
if ( !firstHitPart && firstNncHitPart )
{
// This happen if we only have NNC geometry in the scene
firstHitPart = firstNncHitPart;
}
}
if ( !firstHitPart ) return false;
@ -206,10 +212,24 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
}
if ( gridLocalCellIndex == cvf::UNDEFINED_SIZE_T )
{
if ( nncIndex != cvf::UNDEFINED_SIZE_T && dynamic_cast<RimEclipseView*>( mainOrComparisonView ) )
{
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( mainOrComparisonView );
if ( eclipseView )
{
RigMainGrid* mainGrid = eclipseView->eclipseCase()->eclipseCaseData()->mainGrid();
const RigConnection& nncConn = mainGrid->nncData()->connections()[nncIndex];
mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( nncConn.m_c1GlobIdx, &gridLocalCellIndex );
}
}
else
{
Riu3dSelectionManager::instance()->deleteAllItems();
return false;
}
}
bool appendToSelection = false;
if ( keyboardModifiers & Qt::ControlModifier )
@ -288,14 +308,29 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
{
gridLocalCellIndex = c2LocalIdx;
gridIndex = c2GridIdx;
if (face == cvf::StructGridInterface::NO_FACE)
{
face = nncConn.m_c1Face;
}
else
{
face = cvf::StructGridInterface::oppositeFace(face);
}
}
else if (gridLocalCellIndex == c2LocalIdx && gridIndex == c2GridIdx)
{
gridLocalCellIndex = c1LocalIdx;
gridIndex = c1GridIdx;
if (face == cvf::StructGridInterface::NO_FACE)
{
face = cvf::StructGridInterface::oppositeFace(nncConn.m_c1Face);
}
else
{
face = cvf::StructGridInterface::oppositeFace(face);
}
}
else
{
// None really matched, error in nnc data.