#8375 NNC : Create NNC generators when NNC data is available

This approach fixes an NNC visibility issue related to use of m_rimFault->faultGeometry()->connectionIndices() before any was assigned in RigMainGrid::distributeNNCsToFaults()
This commit is contained in:
Magne Sjaastad 2021-12-20 08:52:22 +01:00
parent 869921d300
commit 8fea45c267
9 changed files with 63 additions and 44 deletions

View File

@ -247,7 +247,7 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode
for ( size_t nIdx = 0; nIdx < nncData->eclipseConnectionCount(); ++nIdx )
{
const RigConnection& conn = nncData->eclipseConnections()[nIdx];
const RigConnection& conn = nncData->availableConnections()[nIdx];
if ( conn.polygon().size() )
{
double resultValue = 0.0;

View File

@ -125,13 +125,16 @@ cvf::ref<cvf::DrawableGeo> RivFaultGeometryGenerator::createOutlineMeshDrawable(
//--------------------------------------------------------------------------------------------------
bool RivFaultGeometryGenerator::hasConnection( size_t cellIdx,
cvf::StructGridInterface::FaceType face,
RigConnectionContainer& conns )
const RigConnectionContainer& conns,
const std::vector<size_t>& nncConnectionIndices )
{
cvf::StructGridInterface::FaceType oppositeFace = cvf::StructGridInterface::oppositeFace( face );
for ( size_t i = 0; i < conns.size(); i++ )
for ( auto i : nncConnectionIndices )
{
auto& r = conns[i];
if ( i >= conns.size() ) continue;
const auto& r = conns[i];
if ( ( r.c1GlobIdx() == cellIdx ) && ( r.face() == face ) && r.hasCommonArea() ) return true;
@ -152,7 +155,8 @@ void RivFaultGeometryGenerator::computeArrays( bool onlyShowFacesWithDefinedNeig
cvf::Vec3d offset = m_grid->displayModelOffset();
auto& connections = m_nncData->connections();
auto connIndices = m_fault->connectionIndices();
auto& connections = m_nncData->availableConnections();
const std::vector<RigFault::FaultFace>& faultFaces = m_fault->faultFaces();
@ -172,7 +176,8 @@ void RivFaultGeometryGenerator::computeArrays( bool onlyShowFacesWithDefinedNeig
if ( !( *m_cellVisibility )[cellIndex] ) continue;
if ( onlyShowFacesWithDefinedNeighbors && !hasConnection( cellIndex, face, connections ) ) continue;
if ( onlyShowFacesWithDefinedNeighbors && !hasConnection( cellIndex, face, connections, connIndices ) )
continue;
cvf::Vec3d cornerVerts[8];
m_grid->cellCornerVertices( cellIndex, cornerVerts );

View File

@ -65,7 +65,10 @@ public:
private:
void computeArrays( bool onlyShowFacesWithDefinedNeighbors );
bool hasConnection( size_t cellIdx, cvf::StructGridInterface::FaceType face, RigConnectionContainer& conns );
bool hasConnection( size_t cellIdx,
cvf::StructGridInterface::FaceType face,
const RigConnectionContainer& conns,
const std::vector<size_t>& nncConnectionIndices );
private:
// Input

View File

@ -72,8 +72,6 @@ RivFaultPartMgr::RivFaultPartMgr( const RigGridBase* grid,
{
CVF_ASSERT( rimFault->faultGeometry() );
cvf::ref<cvf::Array<size_t>> connIdxes = new cvf::Array<size_t>;
connIdxes->assign( rimFault->faultGeometry()->connectionIndices() );
m_nativeFaultGenerator =
new RivFaultGeometryGenerator( grid, rimFault->faultGeometry(), grid->mainGrid()->nncData(), true );
@ -84,18 +82,8 @@ RivFaultPartMgr::RivFaultPartMgr( const RigGridBase* grid,
m_nativeFaultFacesTextureCoords = new cvf::Vec2fArray;
m_oppositeFaultFacesTextureCoords = new cvf::Vec2fArray;
m_NNCGenerator = new RivNNCGeometryGenerator( false,
grid->mainGrid()->nncData(),
grid->mainGrid()->displayModelOffset(),
connIdxes.p() );
m_NNCTextureCoords = new cvf::Vec2fArray;
m_allanNNCGenerator = new RivNNCGeometryGenerator( true,
grid->mainGrid()->nncData(),
grid->mainGrid()->displayModelOffset(),
connIdxes.p() );
m_allanNNCTextureCoords = new cvf::Vec2fArray;
}
@ -106,8 +94,9 @@ void RivFaultPartMgr::setCellVisibility( cvf::UByteArray* cellVisibilities )
{
m_nativeFaultGenerator->setCellVisibility( cellVisibilities );
m_oppositeFaultGenerator->setCellVisibility( cellVisibilities );
m_NNCGenerator->setCellVisibility( cellVisibilities, m_grid.p() );
m_allanNNCGenerator->setCellVisibility( cellVisibilities, m_grid.p() );
if ( m_NNCGenerator.notNull() ) m_NNCGenerator->setCellVisibility( cellVisibilities, m_grid.p() );
if ( m_allanNNCGenerator.notNull() ) m_allanNNCGenerator->setCellVisibility( cellVisibilities, m_grid.p() );
clearFlags();
}
@ -403,6 +392,20 @@ void RivFaultPartMgr::generatePartGeometry()
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::generateNativeNncPartGeometry()
{
if ( m_NNCGenerator.isNull() )
{
auto nncConnectionIndices = m_rimFault->faultGeometry()->connectionIndices();
if ( !nncConnectionIndices.empty() )
{
m_NNCGenerator = new RivNNCGeometryGenerator( false,
m_grid->mainGrid()->nncData(),
m_grid->mainGrid()->displayModelOffset(),
nncConnectionIndices );
}
}
if ( m_NNCGenerator.isNull() ) return;
cvf::ref<cvf::DrawableGeo> geo = m_NNCGenerator->generateSurface();
if ( geo.notNull() )
{
@ -438,6 +441,20 @@ void RivFaultPartMgr::generateNativeNncPartGeometry()
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::generateAllNncPartGeometry()
{
if ( m_allanNNCGenerator.isNull() )
{
auto nncConnectionIndices = m_rimFault->faultGeometry()->connectionIndices();
if ( !nncConnectionIndices.empty() )
{
m_allanNNCGenerator = new RivNNCGeometryGenerator( true,
m_grid->mainGrid()->nncData(),
m_grid->mainGrid()->displayModelOffset(),
nncConnectionIndices );
}
}
if ( m_allanNNCGenerator.isNull() ) return;
cvf::ref<cvf::DrawableGeo> geo = m_allanNNCGenerator->generateSurface();
if ( geo.notNull() )
{

View File

@ -31,10 +31,10 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivNNCGeometryGenerator::RivNNCGeometryGenerator( bool includeAllan,
RigNNCData* nncData,
const cvf::Vec3d& offset,
const cvf::Array<size_t>* nncIndexes )
RivNNCGeometryGenerator::RivNNCGeometryGenerator( bool includeAllan,
RigNNCData* nncData,
const cvf::Vec3d& offset,
const std::vector<size_t>& nncIndexes )
: m_includeAllanDiagramGeometry( includeAllan )
, m_nncData( nncData )
, m_nncIndexes( nncIndexes )
@ -76,7 +76,7 @@ void RivNNCGeometryGenerator::computeArrays()
const cvf::Vec3f offset( m_offset );
long long numConnections =
static_cast<long long>( m_nncIndexes.isNull() ? m_nncData->allConnections().size() : m_nncIndexes->size() );
static_cast<long long>( m_nncIndexes.empty() ? m_nncData->allConnections().size() : m_nncIndexes.size() );
bool isVisibilityCalcActive = m_cellVisibility.notNull() && m_grid.notNull();
std::vector<RigCell>* allCells = nullptr;
@ -88,7 +88,7 @@ void RivNNCGeometryGenerator::computeArrays()
#pragma omp parallel for ordered
for ( long long nIdx = 0; nIdx < numConnections; ++nIdx )
{
size_t conIdx = m_nncIndexes.isNull() ? nIdx : ( *m_nncIndexes )[nIdx];
size_t conIdx = m_nncIndexes.empty() ? nIdx : m_nncIndexes[nIdx];
if ( !m_includeAllanDiagramGeometry && conIdx >= m_nncData->eclipseConnectionCount() )
{

View File

@ -42,10 +42,10 @@ class RigEclipseResultAddress;
class RivNNCGeometryGenerator : public cvf::Object
{
public:
RivNNCGeometryGenerator( bool includeAllan,
RigNNCData* nncData,
const cvf::Vec3d& offset,
const cvf::Array<size_t>* nncIndexes );
RivNNCGeometryGenerator( bool includeAllan,
RigNNCData* nncData,
const cvf::Vec3d& offset,
const std::vector<size_t>& nncIndexes );
~RivNNCGeometryGenerator() override;
@ -70,11 +70,11 @@ private:
bool m_includeAllanDiagramGeometry;
// Input
cvf::ref<RigNNCData> m_nncData;
cvf::cref<cvf::Array<size_t>> m_nncIndexes;
cvf::cref<cvf::UByteArray> m_cellVisibility;
cvf::cref<RigGridBase> m_grid;
cvf::Vec3d m_offset;
cvf::ref<RigNNCData> m_nncData;
std::vector<size_t> m_nncIndexes;
cvf::cref<cvf::UByteArray> m_cellVisibility;
cvf::cref<RigGridBase> m_grid;
cvf::Vec3d m_offset;
// Triangles
cvf::ref<cvf::Vec3fArray> m_vertices;

View File

@ -79,12 +79,6 @@ void RigActiveCellInfo::setCellResultIndex( size_t reservoirCellIndex, size_t re
CVF_TIGHT_ASSERT( reservoirCellResultIndex < m_cellIndexToResultIndex.size() );
m_cellIndexToResultIndex[reservoirCellIndex] = reservoirCellResultIndex;
// if ( reservoirCellResultIndex >= m_reservoirActiveCellCount )
// {
//#pragma omp critical
// m_reservoirActiveCellCount = reservoirCellResultIndex + 1;
// }
}
//--------------------------------------------------------------------------------------------------

View File

@ -265,7 +265,7 @@ size_t RigNNCData::eclipseConnectionCount() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigConnectionContainer& RigNNCData::eclipseConnections() const
const RigConnectionContainer& RigNNCData::availableConnections() const
{
// Return connections without calling ensureConnectionDataIsProcessed() to avoid potential heavy computations
// Relevant if only native connection data is required

View File

@ -57,7 +57,7 @@ public:
void setEclipseConnections( RigConnectionContainer& eclipseConnections );
void buildPolygonsForEclipseConnections();
size_t eclipseConnectionCount() const;
const RigConnectionContainer& eclipseConnections() const;
const RigConnectionContainer& availableConnections() const;
bool ensureAllConnectionDataIsProcessed();
RigConnectionContainer& allConnections();