mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Improve NNC memory use
This commit is contained in:
parent
97dd891d38
commit
ab0b05b31c
@ -734,9 +734,8 @@ void RifReaderEclipseOutput::transferStaticNNCData( const ecl_grid_type* mainEcl
|
||||
RigGridBase* grid1 = mainGrid->gridByIndex( geometry_pair->grid_nr1 );
|
||||
RigGridBase* grid2 = mainGrid->gridByIndex( geometry_pair->grid_nr2 );
|
||||
|
||||
RigConnection nncConnection;
|
||||
nncConnection.m_c1GlobIdx = grid1->reservoirCellIndex( geometry_pair->global_index1 );
|
||||
nncConnection.m_c2GlobIdx = grid2->reservoirCellIndex( geometry_pair->global_index2 );
|
||||
RigConnection nncConnection( grid1->reservoirCellIndex( geometry_pair->global_index1 ),
|
||||
grid2->reservoirCellIndex( geometry_pair->global_index2 ) );
|
||||
|
||||
nncConnections.push_back( nncConnection );
|
||||
|
||||
|
@ -97,9 +97,9 @@ grpc::Status RiaNNCConnectionsStateHandler::assignReply( rips::NNCConnections* r
|
||||
reply->mutable_connections()->Reserve( (int)packageSize );
|
||||
for ( ; indexInPackage < packageSize && m_currentIdx < connectionCount; ++indexInPackage )
|
||||
{
|
||||
RigConnection connection = connections[m_currentIdx];
|
||||
const RigCell& cell1 = mainGrid->globalCellArray()[connection.m_c1GlobIdx];
|
||||
const RigCell& cell2 = mainGrid->globalCellArray()[connection.m_c2GlobIdx];
|
||||
const RigConnection& connection = connections[m_currentIdx];
|
||||
const RigCell& cell1 = mainGrid->globalCellArray()[connection.c1GlobIdx()];
|
||||
const RigCell& cell2 = mainGrid->globalCellArray()[connection.c2GlobIdx()];
|
||||
|
||||
NNCConnection* nncConnection = reply->add_connections();
|
||||
nncConnection->set_allocated_cell1( createConnectionVec3i( cell1 ) );
|
||||
|
@ -97,7 +97,7 @@ void RivNNCGeometryGenerator::computeArrays()
|
||||
|
||||
const RigConnection& conn = m_nncData->connections()[conIdx];
|
||||
|
||||
if ( conn.m_polygon.size() )
|
||||
if ( conn.polygon().size() )
|
||||
{
|
||||
bool isVisible = true;
|
||||
if ( isVisibilityCalcActive )
|
||||
@ -105,15 +105,15 @@ void RivNNCGeometryGenerator::computeArrays()
|
||||
bool cell1Visible = false;
|
||||
bool cell2Visible = false;
|
||||
|
||||
if ( ( *allCells )[conn.m_c1GlobIdx].hostGrid() == m_grid.p() )
|
||||
if ( ( *allCells )[conn.c1GlobIdx()].hostGrid() == m_grid.p() )
|
||||
{
|
||||
size_t cell1GridLocalIdx = ( *allCells )[conn.m_c1GlobIdx].gridLocalCellIndex();
|
||||
size_t cell1GridLocalIdx = ( *allCells )[conn.c1GlobIdx()].gridLocalCellIndex();
|
||||
cell1Visible = ( *m_cellVisibility )[cell1GridLocalIdx];
|
||||
}
|
||||
|
||||
if ( ( *allCells )[conn.m_c2GlobIdx].hostGrid() == m_grid.p() )
|
||||
if ( ( *allCells )[conn.c2GlobIdx()].hostGrid() == m_grid.p() )
|
||||
{
|
||||
size_t cell2GridLocalIdx = ( *allCells )[conn.m_c2GlobIdx].gridLocalCellIndex();
|
||||
size_t cell2GridLocalIdx = ( *allCells )[conn.c2GlobIdx()].gridLocalCellIndex();
|
||||
cell2Visible = ( *m_cellVisibility )[cell2GridLocalIdx];
|
||||
}
|
||||
|
||||
@ -122,14 +122,14 @@ void RivNNCGeometryGenerator::computeArrays()
|
||||
|
||||
if ( isVisible )
|
||||
{
|
||||
cvf::Vec3f vx1 = conn.m_polygon[0] - offset;
|
||||
cvf::Vec3f vx1 = conn.polygon()[0] - offset;
|
||||
cvf::Vec3f vx2;
|
||||
cvf::Vec3f vx3 = conn.m_polygon[1] - offset;
|
||||
cvf::Vec3f vx3 = conn.polygon()[1] - offset;
|
||||
|
||||
for ( size_t vxIdx = 2; vxIdx < conn.m_polygon.size(); ++vxIdx )
|
||||
for ( size_t vxIdx = 2; vxIdx < conn.polygon().size(); ++vxIdx )
|
||||
{
|
||||
vx2 = vx3;
|
||||
vx3 = conn.m_polygon[vxIdx] - offset;
|
||||
vx3 = conn.polygon()[vxIdx] - offset;
|
||||
#pragma omp critical( critical_section_RivNNCGeometryGenerator_computeArrays )
|
||||
{
|
||||
vertices.push_back( vx1 );
|
||||
|
@ -280,7 +280,7 @@ void RimFaultInViewCollection::syncronizeFaults()
|
||||
{
|
||||
size_t gridLocalCellIndex;
|
||||
const RigGridBase* hostGrid =
|
||||
mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( nncConnections[connIndex].m_c1GlobIdx,
|
||||
mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( nncConnections[connIndex].c1GlobIdx(),
|
||||
&gridLocalCellIndex );
|
||||
|
||||
size_t i, j, k;
|
||||
@ -303,7 +303,7 @@ void RimFaultInViewCollection::syncronizeFaults()
|
||||
{
|
||||
size_t gridLocalCellIndex;
|
||||
const RigGridBase* hostGrid =
|
||||
mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( nncConnections[connIndex].m_c2GlobIdx,
|
||||
mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( nncConnections[connIndex].c2GlobIdx(),
|
||||
&gridLocalCellIndex );
|
||||
|
||||
size_t i, j, k;
|
||||
|
@ -2323,9 +2323,10 @@ void RigCaseCellResultsData::computeNncCombRiTrans()
|
||||
const RigConnectionContainer& nncConnections = m_ownerMainGrid->nncData()->connections();
|
||||
for ( size_t connIdx = 0; connIdx < nncConnections.size(); connIdx++ )
|
||||
{
|
||||
size_t nativeResvCellIndex = nncConnections[connIdx].m_c1GlobIdx;
|
||||
size_t neighborResvCellIdx = nncConnections[connIdx].m_c2GlobIdx;
|
||||
cvf::StructGridInterface::FaceType faceId = nncConnections[connIdx].m_c1Face;
|
||||
size_t nativeResvCellIndex = nncConnections[connIdx].c1GlobIdx();
|
||||
size_t neighborResvCellIdx = nncConnections[connIdx].c2GlobIdx();
|
||||
cvf::StructGridInterface::FaceType faceId =
|
||||
static_cast<cvf::StructGridInterface::FaceType>( nncConnections[connIdx].face() );
|
||||
|
||||
ResultIndexFunction permIdxFunc = nullptr;
|
||||
std::vector<double>* permResults = nullptr;
|
||||
@ -2370,7 +2371,7 @@ void RigCaseCellResultsData::computeNncCombRiTrans()
|
||||
cvf::Vec3f faceCenter = cvf::Vec3f::ZERO;
|
||||
|
||||
// Polygon center
|
||||
const std::vector<cvf::Vec3f>& realPolygon = nncConnections[connIdx].m_polygon;
|
||||
const std::vector<cvf::Vec3f>& realPolygon = nncConnections[connIdx].polygon();
|
||||
for ( size_t pIdx = 0; pIdx < realPolygon.size(); ++pIdx )
|
||||
{
|
||||
faceCenter += realPolygon[pIdx];
|
||||
@ -2686,7 +2687,7 @@ void RigCaseCellResultsData::computeNncCombRiTRANSbyArea()
|
||||
|
||||
for ( size_t nncConIdx = 0; nncConIdx < riAreaNormTransResults.size(); ++nncConIdx )
|
||||
{
|
||||
const std::vector<cvf::Vec3f>& realPolygon = connections[nncConIdx].m_polygon;
|
||||
const std::vector<cvf::Vec3f>& realPolygon = connections[nncConIdx].polygon();
|
||||
cvf::Vec3f faceAreaVec = cvf::GeometryTools::polygonAreaNormal3D( realPolygon );
|
||||
double areaOfOverlap = faceAreaVec.length();
|
||||
|
||||
@ -3166,8 +3167,8 @@ void RigCaseCellResultsData::computeAllanResults( RigCaseCellResultsData* cellRe
|
||||
{
|
||||
const auto& c = nncConnections[i];
|
||||
|
||||
size_t globCellIdx1 = c.m_c1GlobIdx;
|
||||
size_t globCellIdx2 = c.m_c2GlobIdx;
|
||||
size_t globCellIdx1 = c.c1GlobIdx();
|
||||
size_t globCellIdx2 = c.c2GlobIdx();
|
||||
|
||||
int formation1 = (int)( fnData[globCellIdx1] );
|
||||
int formation2 = (int)( fnData[globCellIdx2] );
|
||||
|
@ -119,23 +119,12 @@ cvf::StructGridInterface::FaceType
|
||||
return cvf::StructGridInterface::NO_FACE;
|
||||
}
|
||||
|
||||
void assignThreadConnections( std::set<std::pair<unsigned, unsigned>>& existingPairs,
|
||||
RigConnectionContainer& allConnections,
|
||||
RigConnectionContainer& threadConnections )
|
||||
void assignThreadConnections( RigConnectionContainer& allConnections, RigConnectionContainer& threadConnections )
|
||||
{
|
||||
for ( size_t i = 0; i < threadConnections.size(); ++i )
|
||||
{
|
||||
#pragma omp critical
|
||||
{
|
||||
RigConnection connection = threadConnections[i];
|
||||
auto it = existingPairs.emplace( connection.m_c1GlobIdx, connection.m_c2GlobIdx );
|
||||
if ( it.second )
|
||||
{
|
||||
allConnections.push_back( connection );
|
||||
}
|
||||
}
|
||||
{
|
||||
allConnections.push_back( threadConnections );
|
||||
}
|
||||
threadConnections.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -155,7 +144,7 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain
|
||||
for ( size_t i = 0; i < nativeConnections.size(); ++i )
|
||||
{
|
||||
RigConnection c = nativeConnections[i];
|
||||
nativeCellPairs.emplace( c.m_c1GlobIdx, c.m_c2GlobIdx );
|
||||
nativeCellPairs.emplace( static_cast<unsigned>( c.c1GlobIdx() ), static_cast<unsigned>( c.c2GlobIdx() ) );
|
||||
}
|
||||
|
||||
if ( nativeConnections.size() != nativeCellPairs.size() )
|
||||
@ -168,8 +157,7 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain
|
||||
|
||||
const cvf::Collection<RigFault>& faults = mainGrid->faults();
|
||||
|
||||
std::set<std::pair<unsigned, unsigned>> existingPairs;
|
||||
RigConnectionContainer otherConnections;
|
||||
RigConnectionContainer otherConnections;
|
||||
|
||||
for ( int faultIdx = 0; faultIdx < (int)faults.size(); faultIdx++ )
|
||||
{
|
||||
@ -195,38 +183,39 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain
|
||||
if ( atLeastOneCellActive ) activeFaceIndices.push_back( faceIdx );
|
||||
}
|
||||
|
||||
size_t totalNumberOfConnections = 0u;
|
||||
#pragma omp parallel
|
||||
{
|
||||
RigConnectionContainer threadConnections;
|
||||
#pragma omp for schedule( guided )
|
||||
#pragma omp for schedule( guided ) reduction( + : totalNumberOfConnections )
|
||||
for ( int activeFaceIdx = 0; activeFaceIdx < static_cast<int>( activeFaceIndices.size() ); activeFaceIdx++ )
|
||||
{
|
||||
size_t faceIdx = activeFaceIndices[activeFaceIdx];
|
||||
const RigFault::FaultFace& f = faultFaces[faceIdx];
|
||||
|
||||
RigConnectionContainer faceConnections = extractConnectionsForFace( f, mainGrid, nativeCellPairs );
|
||||
threadConnections.insert( faceConnections );
|
||||
size_t faceIdx = activeFaceIndices[activeFaceIdx];
|
||||
extractConnectionsForFace( faultFaces[faceIdx], mainGrid, nativeCellPairs, threadConnections );
|
||||
}
|
||||
#pragma omp barrier
|
||||
otherConnections.reserve( otherConnections.size() + totalNumberOfConnections );
|
||||
|
||||
// Merge together connections per thread
|
||||
assignThreadConnections( existingPairs, otherConnections, threadConnections );
|
||||
assignThreadConnections( otherConnections, threadConnections );
|
||||
} // end parallel region
|
||||
}
|
||||
|
||||
otherConnections.remove_duplicates();
|
||||
return otherConnections;
|
||||
}
|
||||
|
||||
RigConnectionContainer
|
||||
RigCellFaceGeometryTools::extractConnectionsForFace( const RigFault::FaultFace& face,
|
||||
const RigMainGrid* mainGrid,
|
||||
const std::set<std::pair<unsigned, unsigned>>& nativeCellPairs )
|
||||
void RigCellFaceGeometryTools::extractConnectionsForFace( const RigFault::FaultFace& face,
|
||||
const RigMainGrid* mainGrid,
|
||||
const std::set<std::pair<unsigned, unsigned>>& nativeCellPairs,
|
||||
RigConnectionContainer& connections )
|
||||
{
|
||||
RigConnectionContainer faceConnections;
|
||||
size_t sourceReservoirCellIndex = face.m_nativeReservoirCellIndex;
|
||||
cvf::StructGridInterface::FaceType sourceCellFace = face.m_nativeFace;
|
||||
|
||||
if ( sourceReservoirCellIndex >= mainGrid->cellCount() )
|
||||
{
|
||||
return {};
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<cvf::Vec3d>& mainGridNodes = mainGrid->nodes();
|
||||
@ -317,7 +306,8 @@ RigConnectionContainer
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<unsigned, unsigned> candidate( sourceReservoirCellIndex, candidateCellIndex );
|
||||
std::pair<unsigned, unsigned> candidate( static_cast<unsigned>( sourceReservoirCellIndex ),
|
||||
static_cast<unsigned>( candidateCellIndex ) );
|
||||
|
||||
if ( nativeCellPairs.count( candidate ) > 0 )
|
||||
{
|
||||
@ -341,17 +331,14 @@ RigConnectionContainer
|
||||
|
||||
if ( foundOverlap )
|
||||
{
|
||||
RigConnection conn;
|
||||
conn.m_c1GlobIdx = sourceReservoirCellIndex;
|
||||
conn.m_c2GlobIdx = candidateCellIndex;
|
||||
conn.m_c1Face = sourceCellFace;
|
||||
RigConnection conn( sourceReservoirCellIndex,
|
||||
candidateCellIndex,
|
||||
sourceCellFace,
|
||||
RigCellFaceGeometryTools::extractPolygon( mainGridNodes, polygon, intersections ) );
|
||||
|
||||
conn.m_polygon = RigCellFaceGeometryTools::extractPolygon( mainGridNodes, polygon, intersections );
|
||||
|
||||
faceConnections.push_back( conn );
|
||||
connections.push_back( conn );
|
||||
}
|
||||
}
|
||||
return faceConnections;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -51,10 +51,10 @@ public:
|
||||
const RigActiveCellInfo* activeCellInfo,
|
||||
bool includeInactiveCells );
|
||||
|
||||
static RigConnectionContainer
|
||||
extractConnectionsForFace( const RigFault::FaultFace& face,
|
||||
static void extractConnectionsForFace( const RigFault::FaultFace& face,
|
||||
const RigMainGrid* mainGrid,
|
||||
const std::set<std::pair<unsigned, unsigned>>& nativeCellPairs );
|
||||
const std::set<std::pair<unsigned, unsigned>>& nativeCellPairs,
|
||||
RigConnectionContainer& connections );
|
||||
static std::vector<cvf::Vec3f> extractPolygon( const std::vector<cvf::Vec3d>& nativeNodes,
|
||||
const std::vector<size_t>& connectionPolygon,
|
||||
const std::vector<cvf::Vec3d>& connectionIntersections );
|
||||
|
@ -176,6 +176,16 @@ size_t RigGridBase::cellIndexFromIJK( size_t i, size_t j, size_t k ) const
|
||||
return ci;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RigGridBase::cellIndexFromIJKUnguarded( size_t i, size_t j, size_t k ) const
|
||||
{
|
||||
size_t ci = i + j * ( m_gridPointDimensions.x() - 1 ) +
|
||||
k * ( ( m_gridPointDimensions.x() - 1 ) * ( m_gridPointDimensions.y() - 1 ) );
|
||||
return ci;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -91,6 +91,7 @@ public:
|
||||
cvf::Vec3d displayModelOffset() const override;
|
||||
|
||||
size_t cellIndexFromIJK( size_t i, size_t j, size_t k ) const override;
|
||||
size_t cellIndexFromIJKUnguarded( size_t i, size_t j, size_t k ) const;
|
||||
bool ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const override;
|
||||
|
||||
bool cellIJKFromCoordinate( const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k ) const override;
|
||||
|
@ -579,16 +579,16 @@ void RigMainGrid::distributeNNCsToFaults()
|
||||
int fIdx1 = RigFaultsPrCellAccumulator::NO_FAULT;
|
||||
int fIdx2 = RigFaultsPrCellAccumulator::NO_FAULT;
|
||||
|
||||
if ( conn.m_c1Face != StructGridInterface::NO_FACE )
|
||||
if ( conn.face() != StructGridInterface::NO_FACE )
|
||||
{
|
||||
fIdx1 = m_faultsPrCellAcc->faultIdx( conn.m_c1GlobIdx, conn.m_c1Face );
|
||||
fIdx2 = m_faultsPrCellAcc->faultIdx( conn.m_c2GlobIdx, StructGridInterface::oppositeFace( conn.m_c1Face ) );
|
||||
fIdx1 = m_faultsPrCellAcc->faultIdx( conn.c1GlobIdx(), conn.face() );
|
||||
fIdx2 = m_faultsPrCellAcc->faultIdx( conn.c2GlobIdx(), StructGridInterface::oppositeFace( conn.face() ) );
|
||||
}
|
||||
|
||||
if ( fIdx1 < 0 && fIdx2 < 0 )
|
||||
{
|
||||
cvf::String lgrString( "Same Grid" );
|
||||
if ( m_cells[conn.m_c1GlobIdx].hostGrid() != m_cells[conn.m_c2GlobIdx].hostGrid() )
|
||||
if ( m_cells[conn.c1GlobIdx()].hostGrid() != m_cells[conn.c2GlobIdx()].hostGrid() )
|
||||
{
|
||||
lgrString = "Different Grid";
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ void RigNNCData::processNativeConnections( const RigMainGrid& mainGrid )
|
||||
|
||||
for ( size_t cnIdx = 0; cnIdx < m_connections.size(); ++cnIdx )
|
||||
{
|
||||
const RigCell& c1 = mainGrid.globalCellArray()[m_connections[cnIdx].m_c1GlobIdx];
|
||||
const RigCell& c2 = mainGrid.globalCellArray()[m_connections[cnIdx].m_c2GlobIdx];
|
||||
const RigCell& c1 = mainGrid.globalCellArray()[m_connections[cnIdx].c1GlobIdx()];
|
||||
const RigCell& c2 = mainGrid.globalCellArray()[m_connections[cnIdx].c2GlobIdx()];
|
||||
|
||||
std::vector<size_t> connectionPolygon;
|
||||
std::vector<cvf::Vec3d> connectionIntersections;
|
||||
@ -53,21 +53,9 @@ void RigNNCData::processNativeConnections( const RigMainGrid& mainGrid )
|
||||
|
||||
if ( connectionFace != cvf::StructGridInterface::NO_FACE )
|
||||
{
|
||||
// Found an overlap polygon. Store data about connection
|
||||
|
||||
m_connections.face( cnIdx ) = connectionFace;
|
||||
|
||||
m_connections.polygon( cnIdx ) =
|
||||
RigCellFaceGeometryTools::extractPolygon( mainGrid.nodes(), connectionPolygon, connectionIntersections );
|
||||
|
||||
// Add to search map, possibly not needed
|
||||
// m_cellIdxToFaceToConnectionIdxMap[m_connections[cnIdx].m_c1GlobIdx][connectionFace].push_back(cnIdx);
|
||||
// m_cellIdxToFaceToConnectionIdxMap[m_connections[cnIdx].m_c2GlobIdx][cvf::StructGridInterface::oppositeFace(connectionFace].push_back(cnIdx);
|
||||
}
|
||||
else
|
||||
{
|
||||
// cvf::Trace::show("NNC: No overlap found for : C1: " + cvf::String((int)m_connections[cnIdx].m_c1GlobIdx)
|
||||
// + "C2: " + cvf::String((int)m_connections[cnIdx].m_c2GlobIdx));
|
||||
m_connections[cnIdx].setFace( connectionFace );
|
||||
m_connections[cnIdx].setPolygon(
|
||||
RigCellFaceGeometryTools::extractPolygon( mainGrid.nodes(), connectionPolygon, connectionIntersections ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -80,13 +68,12 @@ void RigNNCData::computeCompleteSetOfNncs( const RigMainGrid* mainGrid,
|
||||
bool includeInactiveCells )
|
||||
{
|
||||
m_nativeConnectionCount = m_connections.size();
|
||||
|
||||
RigConnectionContainer otherConnections =
|
||||
RigCellFaceGeometryTools::computeOtherNncs( mainGrid, m_connections, activeCellInfo, includeInactiveCells );
|
||||
|
||||
if ( !otherConnections.empty() )
|
||||
{
|
||||
m_connections.insert( otherConnections );
|
||||
m_connections.push_back( otherConnections );
|
||||
|
||||
// Transmissibility values from Eclipse has been read into propertyNameCombTrans in
|
||||
// RifReaderEclipseOutput::transferStaticNNCData(). Initialize computed NNCs with zero transmissibility
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include "RigNncConnection.h"
|
||||
|
||||
#include "cvfMath.h"
|
||||
#include "cvfAssert.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -26,7 +26,7 @@
|
||||
RigConnection::RigConnection()
|
||||
: m_c1GlobIdx( cvf::UNDEFINED_UINT )
|
||||
, m_c2GlobIdx( cvf::UNDEFINED_UINT )
|
||||
, m_c1Face( cvf::StructGridInterface::NO_FACE )
|
||||
, m_c1Face( static_cast<unsigned char>( cvf::StructGridInterface::NO_FACE ) )
|
||||
{
|
||||
}
|
||||
|
||||
@ -39,11 +39,26 @@ RigConnection::RigConnection( unsigned c1GlobIdx,
|
||||
const std::vector<cvf::Vec3f>& polygon )
|
||||
: m_c1GlobIdx( c1GlobIdx )
|
||||
, m_c2GlobIdx( c2GlobIdx )
|
||||
, m_c1Face( c1Face )
|
||||
, m_c1Face( static_cast<unsigned char>( c1Face ) )
|
||||
, m_polygon( polygon )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigConnection::RigConnection( size_t c1GlobIdx,
|
||||
size_t c2GlobIdx,
|
||||
cvf::StructGridInterface::FaceType c1Face,
|
||||
const std::vector<cvf::Vec3f>& polygon )
|
||||
: m_c1GlobIdx( static_cast<unsigned>( c1GlobIdx ) )
|
||||
, m_c2GlobIdx( static_cast<unsigned>( c2GlobIdx ) )
|
||||
, m_c1Face( static_cast<unsigned char>( c1Face ) )
|
||||
, m_polygon( polygon )
|
||||
{
|
||||
CVF_ASSERT( c1GlobIdx < std::numeric_limits<unsigned>::max() && c2GlobIdx < std::numeric_limits<unsigned>::max() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -58,7 +73,7 @@ RigConnection::RigConnection( const RigConnection& rhs )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigConnection& RigConnection::operator=( RigConnection& rhs )
|
||||
RigConnection& RigConnection::operator=( const RigConnection& rhs )
|
||||
{
|
||||
m_c1GlobIdx = rhs.m_c1GlobIdx;
|
||||
m_c2GlobIdx = rhs.m_c2GlobIdx;
|
||||
@ -75,6 +90,14 @@ bool RigConnection::hasCommonArea() const
|
||||
return m_polygon.size() > 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigConnection::operator==( const RigConnection& rhs )
|
||||
{
|
||||
return m_c1GlobIdx == rhs.m_c1GlobIdx && m_c2GlobIdx == rhs.m_c2GlobIdx;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -91,37 +114,17 @@ bool RigConnection::operator<( const RigConnection& other ) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigConnection RigConnectionContainer::operator[]( size_t i ) const
|
||||
const RigConnection& RigConnectionContainer::operator[]( size_t i ) const
|
||||
{
|
||||
const auto& globIndices = m_globalIndices[i];
|
||||
return RigConnection( globIndices.first,
|
||||
globIndices.second,
|
||||
static_cast<cvf::StructGridInterface::FaceType>( m_faces[i] ),
|
||||
m_polygons[i] );
|
||||
return m_connections[i];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<unsigned, unsigned>& RigConnectionContainer::indexPair( size_t i )
|
||||
RigConnection& RigConnectionContainer::operator[]( size_t i )
|
||||
{
|
||||
return m_globalIndices[i];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
unsigned char& RigConnectionContainer::face( size_t i )
|
||||
{
|
||||
return m_faces[i];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::Vec3f>& RigConnectionContainer::polygon( size_t i )
|
||||
{
|
||||
return m_polygons[i];
|
||||
return m_connections[i];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -129,19 +132,15 @@ std::vector<cvf::Vec3f>& RigConnectionContainer::polygon( size_t i )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigConnectionContainer::push_back( const RigConnection& connection )
|
||||
{
|
||||
m_globalIndices.push_back( std::make_pair( connection.m_c1GlobIdx, connection.m_c2GlobIdx ) );
|
||||
m_faces.push_back( connection.m_c1Face );
|
||||
m_polygons.push_back( connection.m_polygon );
|
||||
m_connections.push_back( connection );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigConnectionContainer::insert( const RigConnectionContainer& other )
|
||||
void RigConnectionContainer::push_back( const RigConnectionContainer& other )
|
||||
{
|
||||
m_globalIndices.insert( m_globalIndices.end(), other.m_globalIndices.begin(), other.m_globalIndices.end() );
|
||||
m_faces.insert( m_faces.end(), other.m_faces.begin(), other.m_faces.end() );
|
||||
m_polygons.insert( m_polygons.end(), other.m_polygons.begin(), other.m_polygons.end() );
|
||||
m_connections.insert( m_connections.end(), other.m_connections.begin(), other.m_connections.end() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -149,7 +148,7 @@ void RigConnectionContainer::insert( const RigConnectionContainer& other )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RigConnectionContainer::size() const
|
||||
{
|
||||
return m_globalIndices.size();
|
||||
return m_connections.size();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -157,9 +156,7 @@ size_t RigConnectionContainer::size() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigConnectionContainer::clear()
|
||||
{
|
||||
m_globalIndices.clear();
|
||||
m_faces.clear();
|
||||
m_polygons.clear();
|
||||
m_connections.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -167,5 +164,25 @@ void RigConnectionContainer::clear()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigConnectionContainer::empty() const
|
||||
{
|
||||
return m_globalIndices.empty();
|
||||
return m_connections.empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigConnectionContainer::remove_duplicates()
|
||||
{
|
||||
std::sort( m_connections.begin(), m_connections.end() );
|
||||
m_connections.erase( std::unique( m_connections.begin(), m_connections.end() ), m_connections.end() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigConnectionContainer::reserve( size_t requiredSize )
|
||||
{
|
||||
if ( m_connections.capacity() < requiredSize )
|
||||
{
|
||||
m_connections.reserve( requiredSize );
|
||||
}
|
||||
}
|
||||
|
@ -33,38 +33,54 @@ public:
|
||||
RigConnection();
|
||||
RigConnection( unsigned c1GlobIdx,
|
||||
unsigned c2GlobIdx,
|
||||
cvf::StructGridInterface::FaceType c1Face,
|
||||
const std::vector<cvf::Vec3f>& polygon );
|
||||
cvf::StructGridInterface::FaceType c1Face = cvf::StructGridInterface::NO_FACE,
|
||||
const std::vector<cvf::Vec3f>& polygon = {} );
|
||||
|
||||
RigConnection( size_t c1GlobIdx,
|
||||
size_t c2GlobIdx,
|
||||
cvf::StructGridInterface::FaceType c1Face = cvf::StructGridInterface::NO_FACE,
|
||||
const std::vector<cvf::Vec3f>& polygon = {} );
|
||||
|
||||
RigConnection( const RigConnection& rhs );
|
||||
|
||||
RigConnection& operator=( RigConnection& rhs );
|
||||
RigConnection& operator=( const RigConnection& rhs );
|
||||
bool operator==( const RigConnection& rhs );
|
||||
bool operator<( const RigConnection& other ) const;
|
||||
bool hasCommonArea() const;
|
||||
|
||||
unsigned m_c1GlobIdx;
|
||||
unsigned m_c2GlobIdx;
|
||||
cvf::StructGridInterface::FaceType m_c1Face;
|
||||
std::vector<cvf::Vec3f> m_polygon;
|
||||
inline size_t c1GlobIdx() const { return m_c1GlobIdx; }
|
||||
inline size_t c2GlobIdx() const { return m_c2GlobIdx; }
|
||||
inline cvf::StructGridInterface::FaceType face() const
|
||||
{
|
||||
return static_cast<cvf::StructGridInterface::FaceType>( m_c1Face );
|
||||
}
|
||||
inline void setFace( cvf::StructGridInterface::FaceType face ) { m_c1Face = static_cast<unsigned char>( face ); }
|
||||
inline const std::vector<cvf::Vec3f>& polygon() const { return m_polygon; }
|
||||
inline void setPolygon( const std::vector<cvf::Vec3f>& polygon ) { m_polygon = polygon; }
|
||||
|
||||
private:
|
||||
unsigned m_c1GlobIdx;
|
||||
unsigned m_c2GlobIdx;
|
||||
unsigned char m_c1Face;
|
||||
std::vector<cvf::Vec3f> m_polygon;
|
||||
};
|
||||
|
||||
class RigConnectionContainer
|
||||
{
|
||||
public:
|
||||
RigConnection operator[]( size_t i ) const;
|
||||
RigConnectionContainer() = default;
|
||||
|
||||
std::pair<unsigned, unsigned>& indexPair( size_t i );
|
||||
unsigned char& face( size_t i );
|
||||
std::vector<cvf::Vec3f>& polygon( size_t i );
|
||||
const RigConnection& operator[]( size_t i ) const;
|
||||
RigConnection& operator[]( size_t i );
|
||||
|
||||
void push_back( const RigConnection& connection );
|
||||
void insert( const RigConnectionContainer& other );
|
||||
void push_back( const RigConnectionContainer& connection );
|
||||
size_t size() const;
|
||||
void clear();
|
||||
bool empty() const;
|
||||
void remove_duplicates();
|
||||
void reserve( size_t requiredSize );
|
||||
|
||||
private:
|
||||
std::vector<std::pair<unsigned, unsigned>> m_globalIndices;
|
||||
std::vector<unsigned char> m_faces;
|
||||
std::vector<std::vector<cvf::Vec3f>> m_polygons;
|
||||
std::vector<RigConnection> m_connections;
|
||||
};
|
||||
|
@ -311,10 +311,10 @@ void RigNumberOfFloodedPoreVolumesCalculator::distributeNNCflow( const RigConnec
|
||||
RigConnection connection = connections[connectionIndex];
|
||||
double connectionValue = flowrateNNC->at( connectionIndex );
|
||||
|
||||
size_t cell1Index = connection.m_c1GlobIdx;
|
||||
size_t cell1Index = connection.c1GlobIdx();
|
||||
size_t cell1ResultIndex = actCellInfo->cellResultIndex( cell1Index );
|
||||
|
||||
size_t cell2Index = connection.m_c2GlobIdx;
|
||||
size_t cell2Index = connection.c2GlobIdx();
|
||||
size_t cell2ResultIndex = actCellInfo->cellResultIndex( cell2Index );
|
||||
|
||||
if ( connectionValue > 0 )
|
||||
|
@ -591,9 +591,7 @@ void RigReservoirBuilderMock::addNnc( RigMainGrid* grid,
|
||||
size_t c1GlobalIndex = grid->cellIndexFromIJK( i1, j1, k1 );
|
||||
size_t c2GlobalIndex = grid->cellIndexFromIJK( i2, j2, k2 );
|
||||
|
||||
RigConnection conn;
|
||||
conn.m_c1GlobIdx = static_cast<unsigned>( c1GlobalIndex );
|
||||
conn.m_c2GlobIdx = static_cast<unsigned>( c2GlobalIndex );
|
||||
RigConnection conn( c1GlobalIndex, c2GlobalIndex );
|
||||
|
||||
nncConnections.push_back( conn );
|
||||
}
|
||||
|
@ -73,8 +73,8 @@ public:
|
||||
{
|
||||
RigConnection connection = mainGrid->nncData()->connections()[i];
|
||||
|
||||
const RigCell& cell1 = mainGrid->globalCellArray()[connection.m_c1GlobIdx];
|
||||
const RigCell& cell2 = mainGrid->globalCellArray()[connection.m_c2GlobIdx];
|
||||
const RigCell& cell1 = mainGrid->globalCellArray()[connection.c1GlobIdx()];
|
||||
const RigCell& cell2 = mainGrid->globalCellArray()[connection.c2GlobIdx()];
|
||||
|
||||
sendCellInfo( socketStream, cell1 );
|
||||
sendCellInfo( socketStream, cell2 );
|
||||
|
@ -221,7 +221,7 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
RigMainGrid* mainGrid = eclipseView->eclipseCase()->eclipseCaseData()->mainGrid();
|
||||
const RigConnection& nncConn = mainGrid->nncData()->connections()[nncIndex];
|
||||
|
||||
mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( nncConn.m_c1GlobIdx, &gridLocalCellIndex );
|
||||
mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( nncConn.c1GlobIdx(), &gridLocalCellIndex );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -298,10 +298,10 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
const RigConnection& nncConn = mainGrid->nncData()->connections()[nncIndex];
|
||||
|
||||
size_t c1LocalIdx = cvf::UNDEFINED_SIZE_T;
|
||||
const RigGridBase* grid1 = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(nncConn.m_c1GlobIdx, &c1LocalIdx);
|
||||
const RigGridBase* grid1 = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(nncConn.c1GlobIdx(), &c1LocalIdx);
|
||||
size_t c1GridIdx = grid1->gridIndex();
|
||||
size_t c2LocalIdx = cvf::UNDEFINED_SIZE_T;
|
||||
const RigGridBase* grid2 = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(nncConn.m_c2GlobIdx, &c2LocalIdx);
|
||||
const RigGridBase* grid2 = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(nncConn.c2GlobIdx(), &c2LocalIdx);
|
||||
size_t c2GridIdx = grid2->gridIndex();
|
||||
|
||||
if (gridLocalCellIndex == c1LocalIdx && gridIndex == c1GridIdx)
|
||||
@ -311,7 +311,7 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
|
||||
if (face == cvf::StructGridInterface::NO_FACE)
|
||||
{
|
||||
face = nncConn.m_c1Face;
|
||||
face = nncConn.face();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -324,7 +324,7 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
gridIndex = c1GridIdx;
|
||||
if (face == cvf::StructGridInterface::NO_FACE)
|
||||
{
|
||||
face = cvf::StructGridInterface::oppositeFace(nncConn.m_c1Face);
|
||||
face = cvf::StructGridInterface::oppositeFace(nncConn.face());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -446,7 +446,7 @@ QString RiuResultTextBuilder::nncResultText()
|
||||
{
|
||||
const RigConnection& conn = nncData->connections()[m_nncIndex];
|
||||
|
||||
cvf::StructGridInterface::FaceEnum face( conn.m_c1Face );
|
||||
cvf::StructGridInterface::FaceEnum face( conn.face() );
|
||||
|
||||
if ( m_viewWithFaultsSettings && m_viewWithFaultsSettings->currentFaultResultColors() )
|
||||
{
|
||||
@ -804,12 +804,12 @@ QString RiuResultTextBuilder::nncDetails()
|
||||
text += "-- NNC details --\n";
|
||||
{
|
||||
const RigConnection& conn = nncData->connections()[m_nncIndex];
|
||||
cvf::StructGridInterface::FaceEnum face( conn.m_c1Face );
|
||||
cvf::StructGridInterface::FaceEnum face( conn.face() );
|
||||
|
||||
// First cell of NNC
|
||||
{
|
||||
CVF_ASSERT( conn.m_c1GlobIdx < grid->globalCellArray().size() );
|
||||
const RigCell& cell = grid->globalCellArray()[conn.m_c1GlobIdx];
|
||||
CVF_ASSERT( conn.c1GlobIdx() < grid->globalCellArray().size() );
|
||||
const RigCell& cell = grid->globalCellArray()[conn.c1GlobIdx()];
|
||||
|
||||
RigGridBase* hostGrid = cell.hostGrid();
|
||||
size_t gridLocalCellIndex = cell.gridLocalCellIndex();
|
||||
@ -834,8 +834,8 @@ QString RiuResultTextBuilder::nncDetails()
|
||||
|
||||
// Second cell of NNC
|
||||
{
|
||||
CVF_ASSERT( conn.m_c2GlobIdx < grid->globalCellArray().size() );
|
||||
const RigCell& cell = grid->globalCellArray()[conn.m_c2GlobIdx];
|
||||
CVF_ASSERT( conn.c2GlobIdx() < grid->globalCellArray().size() );
|
||||
const RigCell& cell = grid->globalCellArray()[conn.c2GlobIdx()];
|
||||
|
||||
RigGridBase* hostGrid = cell.hostGrid();
|
||||
size_t gridLocalCellIndex = cell.gridLocalCellIndex();
|
||||
|
Loading…
Reference in New Issue
Block a user