diff --git a/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp b/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp index b91cd3ecc4..0e33d3bce5 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp @@ -304,8 +304,18 @@ void RigCellFaceGeometryTools::extractConnectionsForFace( const RigFault::FaultF } } - std::pair candidate( static_cast( sourceReservoirCellIndex ), - static_cast( candidateCellIndex ) ); + // Test if this pair of cells already has a connection. Check both combinations of cell index ordering to avoid + // duplicate NNC geometry for the same pair of cells + + auto candidate = std::make_pair( static_cast( sourceReservoirCellIndex ), + static_cast( candidateCellIndex ) ); + + if ( nativeCellPairs.count( candidate ) > 0 ) + { + continue; + } + + std::swap( candidate.first, candidate.second ); if ( nativeCellPairs.count( candidate ) > 0 ) { diff --git a/ApplicationLibCode/ReservoirDataModel/RigFault.cpp b/ApplicationLibCode/ReservoirDataModel/RigFault.cpp index 9df8d36d34..04b9cb6b78 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFault.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigFault.cpp @@ -203,3 +203,33 @@ void RigFault::accumulateFaultsPrCell( RigFaultsPrCellAccumulator* faultsPrCellA faultIdx ); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFaultsPrCellAccumulator::RigFaultsPrCellAccumulator( size_t reservoirCellCount ) +{ + std::array initVals = { NO_FAULT, NO_FAULT, NO_FAULT, NO_FAULT, NO_FAULT, NO_FAULT }; + m_faultIdxForCellFace.resize( reservoirCellCount, initVals ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RigFaultsPrCellAccumulator::faultIdx( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face ) const +{ + // Ensure no crash after creating temporary LGRs + if ( reservoirCellIndex < m_faultIdxForCellFace.size() ) + { + return m_faultIdxForCellFace[reservoirCellIndex][face]; + } + return NO_FAULT; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFaultsPrCellAccumulator::setFaultIdx( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face, int faultIdx ) +{ + m_faultIdxForCellFace[reservoirCellIndex][face] = faultIdx; +} diff --git a/ApplicationLibCode/ReservoirDataModel/RigFault.h b/ApplicationLibCode/ReservoirDataModel/RigFault.h index d498763129..a763a7bff9 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFault.h +++ b/ApplicationLibCode/ReservoirDataModel/RigFault.h @@ -46,26 +46,11 @@ public: }; public: - explicit RigFaultsPrCellAccumulator( size_t reservoirCellCount ) - { - std::array initVals = {NO_FAULT, NO_FAULT, NO_FAULT, NO_FAULT, NO_FAULT, NO_FAULT}; - m_faultIdxForCellFace.resize( reservoirCellCount, initVals ); - } + explicit RigFaultsPrCellAccumulator( size_t reservoirCellCount ); - inline int faultIdx( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face ) const - { - // Ensure no crash after creating temporary LGRs - if ( reservoirCellIndex < m_faultIdxForCellFace.size() ) - { - return m_faultIdxForCellFace[reservoirCellIndex][face]; - } - return NO_FAULT; - } + int faultIdx( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face ) const; - inline void setFaultIdx( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face, int faultIdx ) - { - m_faultIdxForCellFace[reservoirCellIndex][face] = faultIdx; - } + void setFaultIdx( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face, int faultIdx ); private: std::vector> m_faultIdxForCellFace; diff --git a/ApplicationLibCode/ReservoirDataModel/RigNncConnection.cpp b/ApplicationLibCode/ReservoirDataModel/RigNncConnection.cpp index 65ba39f922..b608ac957f 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigNncConnection.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigNncConnection.cpp @@ -45,10 +45,14 @@ RigConnection::RigConnection( unsigned c1GlobIdx, if ( c1GlobIdx >= c2GlobIdx ) { // Ensure the smallest cell index is the first index - // TODO : The face type is related to cell 1, so face should be changed to opposite face - // This causes visual artifacts for some models, so this change will require more investigation m_c1GlobIdx = c2GlobIdx; m_c2GlobIdx = c1GlobIdx; + + if ( c1Face != cvf::StructGridInterface::FaceType::NO_FACE ) + { + // The face type is related to cell 1, so use opposite face + m_c1Face = cvf::StructGridInterface::oppositeFace( c1Face ); + } } } @@ -69,10 +73,14 @@ RigConnection::RigConnection( size_t c1GlobIdx, if ( c1GlobIdx >= c2GlobIdx ) { // Ensure the smallest cell index is the first index - // TODO : The face type is related to cell 1, so face should be changed to opposite face - // This causes visual artifacts for some models, so this change will require more investigation m_c1GlobIdx = static_cast( c2GlobIdx ); m_c2GlobIdx = static_cast( c1GlobIdx ); + + if ( c1Face != cvf::StructGridInterface::FaceType::NO_FACE ) + { + // The face type is related to cell 1, so use opposite face + m_c1Face = cvf::StructGridInterface::oppositeFace( c1Face ); + } } } diff --git a/GrpcInterface/Python/rips/tests/test_nnc_properties.py b/GrpcInterface/Python/rips/tests/test_nnc_properties.py index e55cd1a289..b5b2fa85d9 100644 --- a/GrpcInterface/Python/rips/tests/test_nnc_properties.py +++ b/GrpcInterface/Python/rips/tests/test_nnc_properties.py @@ -25,7 +25,7 @@ def test_10kSync(rips_instance, initialize_test): ) nnc_connections = case.nnc_connections() - assert len(nnc_connections) == 3627 + assert len(nnc_connections) == 3416 connection = nnc_connections[0] assert connection.cell1.i == 33