#5915 improve performance of NNC computation and limit to active cells

This commit is contained in:
Gaute Lindkvist 2020-05-12 18:19:27 +02:00
parent 3d2ac4b573
commit f199297f12
21 changed files with 463 additions and 278 deletions

View File

@ -396,9 +396,9 @@ if (MSVC)
# warning C4005: Macro redefinition for math constants (M_PI, M_SQRT2 etc)
# If possible, the following command is supposed to be the final target
# set_target_properties(ResInsight PROPERTIES COMPILE_FLAGS "/W4 /wd4190 /wd4100 /wd4127")
# set_target_properties(ResInsight PROPERTIES COMPILE_FLAGS "/W3 /wd4190 /wd4100 /wd4127")
set_target_properties(ResInsight PROPERTIES COMPILE_FLAGS "/W4 /wd4190 /wd4100 /wd4127 /wd4245 /wd4005")
set_target_properties(ResInsight PROPERTIES COMPILE_FLAGS "/W3 /wd4190 /wd4100 /wd4127 /wd4245 /wd4005")
if (CMAKE_CXX_COMPILER_VERSION LESS_EQUAL 19.14)
# The following warning is generated over 800 times from a qwt header only using VS2015
# Disabling temporarily

View File

@ -723,8 +723,8 @@ void RifReaderEclipseOutput::transferStaticNNCData( const ecl_grid_type* mainEcl
if ( numNNC > 0 )
{
// Transform to our own data structures
std::vector<RigConnection> nncConnections;
std::vector<double> transmissibilityValuesTemp;
RigConnectionContainer nncConnections;
std::vector<double> transmissibilityValuesTemp;
const double* transValues = ecl_nnc_data_get_values( tran_data );
@ -1289,7 +1289,7 @@ size_t localGridCellIndexFromErtConnection( const RigGridBase* grid,
cellK = 0;
}
// Introduced based on discussion with Håkon Høgstøl 08.09.2016
// Introduced based on discussion with H<EFBFBD>kon H<>gst<73>l 08.09.2016
if ( cellK >= static_cast<int>( grid->cellCountK() ) )
{
int maxCellK = static_cast<int>( grid->cellCountK() );

View File

@ -26,7 +26,7 @@ def test_10kSync(rips_instance, initialize_test):
assert(NNCProperties_pb2.NNCPropertyType.Value('NNC_GENERATED') == properties[2].property_type)
nnc_connections = case.nnc_connections()
assert(len(nnc_connections) == 84759)
assert(len(nnc_connections) == 3416)
connection = nnc_connections[0]
assert(connection.cell1.i == 33)

View File

@ -88,8 +88,8 @@ rips::Vec3i* createConnectionVec3i( const RigCell& cell )
//--------------------------------------------------------------------------------------------------
grpc::Status RiaNNCConnectionsStateHandler::assignReply( rips::NNCConnections* reply )
{
RigMainGrid* mainGrid = m_eclipseCase->eclipseCaseData()->mainGrid();
std::vector<RigConnection> connections = mainGrid->nncData()->connections();
RigMainGrid* mainGrid = m_eclipseCase->eclipseCaseData()->mainGrid();
const RigConnectionContainer& connections = mainGrid->nncData()->connections();
size_t connectionCount = connections.size();
const size_t packageSize = RiaGrpcServiceInterface::numberOfDataUnitsInPackage( sizeof( rips::NNCConnection ) );
@ -97,7 +97,7 @@ 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];
RigConnection connection = connections[m_currentIdx];
const RigCell& cell1 = mainGrid->globalCellArray()[connection.m_c1GlobIdx];
const RigCell& cell2 = mainGrid->globalCellArray()[connection.m_c2GlobIdx];
@ -188,8 +188,8 @@ const std::vector<double>* getScalarResultByName( const RigNNCData* nncD
//--------------------------------------------------------------------------------------------------
grpc::Status RiaNNCValuesStateHandler::assignReply( rips::NNCValues* reply )
{
RigMainGrid* mainGrid = m_eclipseCase->eclipseCaseData()->mainGrid();
std::vector<RigConnection> connections = mainGrid->nncData()->connections();
RigMainGrid* mainGrid = m_eclipseCase->eclipseCaseData()->mainGrid();
auto connections = mainGrid->nncData()->connections();
QString propertyName = QString::fromStdString( m_request->property_name() );
RigNNCData::NNCResultType propertyType = static_cast<RigNNCData::NNCResultType>( m_request->property_type() );
@ -496,31 +496,32 @@ std::vector<RiaGrpcCallbackInterface*> RiaGrpcNNCPropertiesService::createCallba
std::vector<RiaGrpcCallbackInterface*> callbacks;
callbacks =
{new RiaGrpcUnaryCallback<Self, CaseRequest, AvailableNNCProperties>( this,
&Self::GetAvailableNNCProperties,
&Self::RequestGetAvailableNNCProperties ),
new RiaGrpcServerToClientStreamCallback<Self,
CaseRequest,
rips::NNCConnections,
RiaNNCConnectionsStateHandler>( this,
&Self::GetNNCConnections,
&Self::RequestGetNNCConnections,
new RiaNNCConnectionsStateHandler ),
new RiaGrpcServerToClientStreamCallback<Self,
NNCValuesRequest,
rips::NNCValues,
RiaNNCValuesStateHandler>( this,
&Self::GetNNCValues,
&Self::RequestGetNNCValues,
new RiaNNCValuesStateHandler ),
{ new RiaGrpcUnaryCallback<Self, CaseRequest, AvailableNNCProperties>( this,
&Self::GetAvailableNNCProperties,
&Self::RequestGetAvailableNNCProperties ),
new RiaGrpcServerToClientStreamCallback<Self,
CaseRequest,
rips::NNCConnections,
RiaNNCConnectionsStateHandler>( this,
&Self::GetNNCConnections,
&Self::RequestGetNNCConnections,
new RiaNNCConnectionsStateHandler ),
new RiaGrpcServerToClientStreamCallback<Self,
NNCValuesRequest,
rips::NNCValues,
RiaNNCValuesStateHandler>( this,
&Self::GetNNCValues,
&Self::RequestGetNNCValues,
new RiaNNCValuesStateHandler ),
new RiaGrpcClientToServerStreamCallback<Self,
NNCValuesChunk,
ClientToServerStreamReply,
RiaNNCInputValuesStateHandler>( this,
&Self::SetNNCValues,
&Self::RequestSetNNCValues,
new RiaNNCInputValuesStateHandler( true ) )};
new RiaGrpcClientToServerStreamCallback<Self,
NNCValuesChunk,
ClientToServerStreamReply,
RiaNNCInputValuesStateHandler>( this,
&Self::SetNNCValues,
&Self::RequestSetNNCValues,
new RiaNNCInputValuesStateHandler(
true ) ) };
return callbacks;
}

View File

@ -266,8 +266,8 @@ void RimFaultInViewCollection::syncronizeFaults()
// NNCs
this->noCommonAreaNnncCollection()->noCommonAreaNncs().deleteAllChildObjects();
RigMainGrid* mainGrid = parentView()->mainGrid();
const std::vector<RigConnection>& nncConnections = mainGrid->nncData()->connections();
RigMainGrid* mainGrid = parentView()->mainGrid();
const RigConnectionContainer& nncConnections = mainGrid->nncData()->connections();
for ( size_t connIndex = 0; connIndex < nncConnections.size(); connIndex++ )
{
if ( !nncConnections[connIndex].hasCommonArea() )

View File

@ -2303,7 +2303,7 @@ void RigCaseCellResultsData::computeNncCombRiTrans()
bool isFaceNormalsOutwards = m_ownerMainGrid->isFaceNormalsOutwards();
// NNC calculation
const std::vector<RigConnection>& nncConnections = m_ownerMainGrid->nncData()->connections();
const RigConnectionContainer& nncConnections = m_ownerMainGrid->nncData()->connections();
for ( size_t connIdx = 0; connIdx < nncConnections.size(); connIdx++ )
{
size_t nativeResvCellIndex = nncConnections[connIdx].m_c1GlobIdx;
@ -2665,7 +2665,7 @@ void RigCaseCellResultsData::computeNncCombRiTRANSbyArea()
if ( transResults->size() != riAreaNormTransResults.size() ) return;
const std::vector<RigConnection>& connections = m_ownerMainGrid->nncData()->connections();
const RigConnectionContainer& connections = m_ownerMainGrid->nncData()->connections();
for ( size_t nncConIdx = 0; nncConIdx < riAreaNormTransResults.size(); ++nncConIdx )
{
@ -3130,7 +3130,7 @@ void RigCaseCellResultsData::computeAllanResults( RigCaseCellResultsData* cellRe
formationCount = cellResultsData->activeFormationNames()->formationNames().size();
}
const std::vector<RigConnection>& nncConnections = mainGrid->nncData()->connections();
const RigConnectionContainer& nncConnections = mainGrid->nncData()->connections();
std::map<std::pair<int, int>, int> formationCombinationToCategory;
for ( size_t i = 0; i < nncConnections.size(); i++ )

View File

@ -18,6 +18,7 @@
#include "RigCellFaceGeometryTools.h"
#include "RigActiveCellInfo.h"
#include "RigCell.h"
#include "RigMainGrid.h"
#include "RigNncConnection.h"
@ -28,6 +29,8 @@
#include <QDebug>
#include <omp.h>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -40,7 +43,7 @@ cvf::StructGridInterface::FaceType
{
// Try to find the shared face
bool isPossibleNeighborInDirection[6] = {true, true, true, true, true, true};
bool isPossibleNeighborInDirection[6] = { true, true, true, true, true, true };
if ( c1.hostGrid() == c2.hostGrid() )
{
@ -116,55 +119,42 @@ cvf::StructGridInterface::FaceType
return cvf::StructGridInterface::NO_FACE;
}
void assignThreadConnections( std::set<std::pair<size_t, size_t>>& existingPairs,
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 );
}
}
}
threadConnections.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigConnection> RigCellFaceGeometryTools::computeOtherNncs( const RigMainGrid* mainGrid,
const std::vector<RigConnection>& nativeConnections )
RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMainGrid* mainGrid,
const RigConnectionContainer& nativeConnections,
const RigActiveCellInfo* activeCellInfo )
{
// Compute Non-Neighbor Connections (NNC) not reported by Eclipse. NNCs with zero transmissibility are not reported
// by Eclipse. Use faults as basis for subset of cells to find NNC connection for. The imported connections from
// Eclipse are located at the beginning of the connections vector.
std::vector<RigConnection> otherConnections;
std::set<std::pair<size_t, size_t>> nativeCellPairs;
class CellPair
for ( size_t i = 0; i < nativeConnections.size(); ++i )
{
public:
CellPair( size_t globalIdx1, size_t globalIdx2 )
{
if ( globalIdx1 < globalIdx2 )
{
m_globalCellIdx1 = globalIdx1;
m_globalCellIdx2 = globalIdx2;
}
else
{
m_globalCellIdx1 = globalIdx2;
m_globalCellIdx2 = globalIdx1;
}
}
bool operator<( const CellPair& other ) const
{
if ( m_globalCellIdx1 != other.m_globalCellIdx1 )
{
return m_globalCellIdx1 < other.m_globalCellIdx1;
}
return ( m_globalCellIdx2 < other.m_globalCellIdx2 );
}
private:
size_t m_globalCellIdx1;
size_t m_globalCellIdx2;
};
std::set<CellPair> nativeCellPairs;
for ( const auto& c : nativeConnections )
{
nativeCellPairs.emplace( CellPair( c.m_c1GlobIdx, c.m_c2GlobIdx ) );
RigConnection c = nativeConnections[i];
nativeCellPairs.emplace( c.m_c1GlobIdx, c.m_c2GlobIdx );
}
if ( nativeConnections.size() != nativeCellPairs.size() )
@ -175,164 +165,181 @@ std::vector<RigConnection> RigCellFaceGeometryTools::computeOtherNncs( const Rig
qDebug() << message;
}
std::set<CellPair> otherCellPairs;
const cvf::Collection<RigFault>& faults = mainGrid->faults();
for ( size_t faultIdx = 0; faultIdx < faults.size(); faultIdx++ )
std::set<std::pair<size_t, size_t>> existingPairs;
RigConnectionContainer otherConnections;
for ( int faultIdx = 0; faultIdx < (int)faults.size(); faultIdx++ )
{
const RigFault* fault = faults.at( faultIdx );
const std::vector<RigFault::FaultFace>& faultFaces = fault->faultFaces();
#pragma omp parallel for
for ( int faceIdx = 0; faceIdx < static_cast<int>( faultFaces.size() ); faceIdx++ )
#pragma omp parallel
{
const RigFault::FaultFace& f = faultFaces[faceIdx];
size_t sourceReservoirCellIndex = f.m_nativeReservoirCellIndex;
cvf::StructGridInterface::FaceType sourceCellFace = f.m_nativeFace;
if ( sourceReservoirCellIndex >= mainGrid->cellCount() )
RigConnectionContainer threadConnections;
#pragma omp for
for ( int faceIdx = 0; faceIdx < static_cast<int>( faultFaces.size() ); faceIdx++ )
{
continue;
}
const RigFault::FaultFace& f = faultFaces[faceIdx];
const std::vector<cvf::Vec3d>& mainGridNodes = mainGrid->nodes();
cvf::BoundingBox bb;
std::array<size_t, 4> sourceFaceIndices;
mainGrid->globalCellArray()[sourceReservoirCellIndex].faceIndices( sourceCellFace, &sourceFaceIndices );
bb.add( mainGridNodes[sourceFaceIndices[0]] );
bb.add( mainGridNodes[sourceFaceIndices[1]] );
bb.add( mainGridNodes[sourceFaceIndices[2]] );
bb.add( mainGridNodes[sourceFaceIndices[3]] );
std::vector<size_t> closeCells;
mainGrid->findIntersectingCells( bb, &closeCells );
cvf::StructGridInterface::FaceType candidateFace = cvf::StructGridInterface::oppositeFace( sourceCellFace );
size_t neighborCellIndex = std::numeric_limits<size_t>::max();
size_t ni = std::numeric_limits<size_t>::max();
size_t nj = std::numeric_limits<size_t>::max();
size_t nk = std::numeric_limits<size_t>::max();
{
size_t i;
size_t j;
size_t k;
mainGrid->ijkFromCellIndex( sourceReservoirCellIndex, &i, &j, &k );
mainGrid->neighborIJKAtCellFace( i, j, k, sourceCellFace, &ni, &nj, &nk );
if ( mainGrid->isCellValid( ni, nj, nk ) )
bool atLeastOneCellActive = !activeCellInfo ||
( activeCellInfo->isActive( f.m_nativeReservoirCellIndex ) ||
activeCellInfo->isActive( f.m_oppositeReservoirCellIndex ) );
if ( atLeastOneCellActive )
{
neighborCellIndex = mainGrid->cellIndexFromIJK( ni, nj, nk );
RigConnectionContainer faceConnections = extractConnectionsForFace( f, mainGrid, nativeCellPairs );
threadConnections.insert( faceConnections );
}
}
for ( size_t candidateCellIndex : closeCells )
{
if ( candidateCellIndex == sourceReservoirCellIndex )
{
// Exclude cellIndex for source cell
continue;
}
if ( candidateCellIndex == neighborCellIndex )
{
// Exclude direct neighbor
continue;
}
if ( candidateCellIndex >= mainGrid->cellCount() )
{
continue;
}
if ( neighborCellIndex != std::numeric_limits<size_t>::max() )
{
// Find target IJK index based on source cell and cell face
// Exclude cells not matching destination target index
size_t ci = std::numeric_limits<size_t>::max();
size_t cj = std::numeric_limits<size_t>::max();
size_t ck = std::numeric_limits<size_t>::max();
mainGrid->ijkFromCellIndex( candidateCellIndex, &ci, &cj, &ck );
auto gridAxis = cvf::StructGridInterface::gridAxisFromFace( sourceCellFace );
if ( gridAxis == cvf::StructGridInterface::GridAxisType::AXIS_I )
{
if ( ni != ci )
{
continue;
}
}
else if ( gridAxis == cvf::StructGridInterface::GridAxisType::AXIS_J )
{
if ( nj != cj )
{
continue;
}
}
else if ( gridAxis == cvf::StructGridInterface::GridAxisType::AXIS_K )
{
if ( nk != ck )
{
continue;
}
}
}
CellPair candidate( sourceReservoirCellIndex, candidateCellIndex );
if ( nativeCellPairs.count( candidate ) > 0 )
{
continue;
}
std::vector<size_t> polygon;
std::vector<cvf::Vec3d> intersections;
std::array<size_t, 4> candidateFaceIndices;
mainGrid->globalCellArray()[candidateCellIndex].faceIndices( candidateFace, &candidateFaceIndices );
bool foundOverlap =
cvf::GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon,
&intersections,
(cvf::EdgeIntersectStorage<size_t>*)nullptr,
cvf::wrapArrayConst( &mainGridNodes ),
sourceFaceIndices.data(),
candidateFaceIndices.data(),
1e-6 );
if ( foundOverlap )
{
RigConnection conn;
conn.m_c1GlobIdx = sourceReservoirCellIndex;
conn.m_c1Face = sourceCellFace;
conn.m_c2GlobIdx = candidateCellIndex;
conn.m_polygon = RigCellFaceGeometryTools::extractPolygon( mainGridNodes, polygon, intersections );
#pragma omp critical( critical_section_nnc_computations )
{
auto itBoolPair = otherCellPairs.insert( candidate );
if ( itBoolPair.second )
{
otherConnections.emplace_back( conn );
}
}
}
}
}
// Merge together connections per thread
assignThreadConnections( existingPairs, otherConnections, threadConnections );
} // end parallel region
}
return otherConnections;
}
RigConnectionContainer
RigCellFaceGeometryTools::extractConnectionsForFace( const RigFault::FaultFace& face,
const RigMainGrid* mainGrid,
const std::set<std::pair<size_t, size_t>>& nativeCellPairs )
{
RigConnectionContainer faceConnections;
size_t sourceReservoirCellIndex = face.m_nativeReservoirCellIndex;
cvf::StructGridInterface::FaceType sourceCellFace = face.m_nativeFace;
if ( sourceReservoirCellIndex >= mainGrid->cellCount() )
{
return {};
}
const std::vector<cvf::Vec3d>& mainGridNodes = mainGrid->nodes();
cvf::BoundingBox bb;
std::array<size_t, 4> sourceFaceIndices;
mainGrid->globalCellArray()[sourceReservoirCellIndex].faceIndices( sourceCellFace, &sourceFaceIndices );
bb.add( mainGridNodes[sourceFaceIndices[0]] );
bb.add( mainGridNodes[sourceFaceIndices[1]] );
bb.add( mainGridNodes[sourceFaceIndices[2]] );
bb.add( mainGridNodes[sourceFaceIndices[3]] );
std::vector<size_t> closeCells;
mainGrid->findIntersectingCells( bb, &closeCells );
cvf::StructGridInterface::FaceType candidateFace = cvf::StructGridInterface::oppositeFace( sourceCellFace );
size_t neighborCellIndex = std::numeric_limits<size_t>::max();
size_t ni = std::numeric_limits<size_t>::max();
size_t nj = std::numeric_limits<size_t>::max();
size_t nk = std::numeric_limits<size_t>::max();
{
size_t i;
size_t j;
size_t k;
mainGrid->ijkFromCellIndex( sourceReservoirCellIndex, &i, &j, &k );
mainGrid->neighborIJKAtCellFace( i, j, k, sourceCellFace, &ni, &nj, &nk );
if ( mainGrid->isCellValid( ni, nj, nk ) )
{
neighborCellIndex = mainGrid->cellIndexFromIJK( ni, nj, nk );
}
}
for ( size_t candidateCellIndex : closeCells )
{
if ( candidateCellIndex == sourceReservoirCellIndex )
{
// Exclude cellIndex for source cell
continue;
}
if ( candidateCellIndex == neighborCellIndex )
{
// Exclude direct neighbor
continue;
}
if ( candidateCellIndex >= mainGrid->cellCount() )
{
continue;
}
if ( neighborCellIndex != std::numeric_limits<size_t>::max() )
{
// Find target IJK index based on source cell and cell face
// Exclude cells not matching destination target index
size_t ci = std::numeric_limits<size_t>::max();
size_t cj = std::numeric_limits<size_t>::max();
size_t ck = std::numeric_limits<size_t>::max();
mainGrid->ijkFromCellIndex( candidateCellIndex, &ci, &cj, &ck );
auto gridAxis = cvf::StructGridInterface::gridAxisFromFace( sourceCellFace );
if ( gridAxis == cvf::StructGridInterface::GridAxisType::AXIS_I )
{
if ( ni != ci )
{
continue;
}
}
else if ( gridAxis == cvf::StructGridInterface::GridAxisType::AXIS_J )
{
if ( nj != cj )
{
continue;
}
}
else if ( gridAxis == cvf::StructGridInterface::GridAxisType::AXIS_K )
{
if ( nk != ck )
{
continue;
}
}
}
std::pair<size_t, size_t> candidate( sourceReservoirCellIndex, candidateCellIndex );
if ( nativeCellPairs.count( candidate ) > 0 )
{
continue;
}
std::vector<size_t> polygon;
std::vector<cvf::Vec3d> intersections;
std::array<size_t, 4> candidateFaceIndices;
mainGrid->globalCellArray()[candidateCellIndex].faceIndices( candidateFace, &candidateFaceIndices );
bool foundOverlap =
cvf::GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon,
&intersections,
(cvf::EdgeIntersectStorage<size_t>*)nullptr,
cvf::wrapArrayConst( &mainGridNodes ),
sourceFaceIndices.data(),
candidateFaceIndices.data(),
1e-6 );
if ( foundOverlap )
{
RigConnection conn;
conn.m_c1GlobIdx = sourceReservoirCellIndex;
conn.m_c2GlobIdx = candidateCellIndex;
conn.m_c1Face = sourceCellFace;
conn.m_polygon = RigCellFaceGeometryTools::extractPolygon( mainGridNodes, polygon, intersections );
faceConnections.push_back( conn );
}
}
return faceConnections;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -18,15 +18,21 @@
#pragma once
#include "RigFault.h"
#include "RigNncConnection.h"
#include "cvfCollection.h"
#include "cvfStructGrid.h"
#include "cvfVector3.h"
#include <deque>
#include <set>
#include <utility>
#include <vector>
class RigActiveCellInfo;
class RigCell;
class RigMainGrid;
class RigConnection;
//==================================================================================================
///
@ -40,9 +46,13 @@ public:
std::vector<size_t>* connectionPolygon,
std::vector<cvf::Vec3d>* connectionIntersections );
static std::vector<RigConnection> computeOtherNncs( const RigMainGrid* mainGrid,
const std::vector<RigConnection>& nativeConnections );
static RigConnectionContainer computeOtherNncs( const RigMainGrid* mainGrid,
const RigConnectionContainer& nativeConnections,
const RigActiveCellInfo* activeCellInfo );
static RigConnectionContainer extractConnectionsForFace( const RigFault::FaultFace& face,
const RigMainGrid* mainGrid,
const std::set<std::pair<size_t, size_t>>& nativeCellPairs );
static std::vector<cvf::Vec3d> extractPolygon( const std::vector<cvf::Vec3d>& nativeNodes,
const std::vector<size_t>& connectionPolygon,
const std::vector<cvf::Vec3d>& connectionIntersections );

View File

@ -556,7 +556,7 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo )
}
}
this->nncData()->computeCompleteSetOfNncs( this );
this->nncData()->computeCompleteSetOfNncs( this, activeCellInfo );
distributeNNCsToFaults();
}
@ -566,7 +566,7 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo )
//--------------------------------------------------------------------------------------------------
void RigMainGrid::distributeNNCsToFaults()
{
const std::vector<RigConnection>& nncs = this->nncData()->connections();
const RigConnectionContainer& nncs = this->nncData()->connections();
for ( size_t nncIdx = 0; nncIdx < nncs.size(); ++nncIdx )
{
// Find the fault for each side of the nnc

View File

@ -55,9 +55,9 @@ void RigNNCData::processNativeConnections( const RigMainGrid& mainGrid )
{
// Found an overlap polygon. Store data about connection
m_connections[cnIdx].m_c1Face = connectionFace;
m_connections.face( cnIdx ) = connectionFace;
m_connections[cnIdx].m_polygon =
m_connections.polygon( cnIdx ) =
RigCellFaceGeometryTools::extractPolygon( mainGrid.nodes(), connectionPolygon, connectionIntersections );
// Add to search map, possibly not needed
@ -75,15 +75,16 @@ void RigNNCData::processNativeConnections( const RigMainGrid& mainGrid )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigNNCData::computeCompleteSetOfNncs( const RigMainGrid* mainGrid )
void RigNNCData::computeCompleteSetOfNncs( const RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo )
{
m_nativeConnectionCount = m_connections.size();
std::vector<RigConnection> otherConnections = RigCellFaceGeometryTools::computeOtherNncs( mainGrid, m_connections );
RigConnectionContainer otherConnections =
RigCellFaceGeometryTools::computeOtherNncs( mainGrid, m_connections, activeCellInfo );
if ( !otherConnections.empty() )
{
m_connections.insert( m_connections.end(), otherConnections.begin(), otherConnections.end() );
m_connections.insert( otherConnections );
// Transmissibility values from Eclipse has been read into propertyNameCombTrans in
// RifReaderEclipseOutput::transferStaticNNCData(). Initialize computed NNCs with zero transmissibility
@ -101,7 +102,7 @@ void RigNNCData::computeCompleteSetOfNncs( const RigMainGrid* mainGrid )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigNNCData::setConnections( std::vector<RigConnection>& connections )
void RigNNCData::setConnections( RigConnectionContainer& connections )
{
m_connections = connections;
}
@ -117,7 +118,7 @@ size_t RigNNCData::nativeConnectionCount() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<RigConnection>& RigNNCData::connections() const
const RigConnectionContainer& RigNNCData::connections() const
{
return m_connections;
}

View File

@ -28,9 +28,11 @@
#include "cvfVector3.h"
#include <cmath> // Needed for HUGE_VAL on Linux
#include <deque>
#include <map>
#include <vector>
class RigActiveCellInfo;
class RigMainGrid;
class RigCell;
class RigEclipseResultAddress;
@ -48,12 +50,12 @@ public:
RigNNCData();
void processNativeConnections( const RigMainGrid& mainGrid );
void computeCompleteSetOfNncs( const RigMainGrid* mainGrid );
void computeCompleteSetOfNncs( const RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo );
void setConnections( std::vector<RigConnection>& connections );
void setConnections( RigConnectionContainer& connections );
size_t nativeConnectionCount() const;
const std::vector<RigConnection>& connections() const;
const RigConnectionContainer& connections() const;
std::vector<double>& makeStaticConnectionScalarResult( QString nncDataType );
const std::vector<double>* staticConnectionScalarResult( const RigEclipseResultAddress& resVarAddr ) const;
@ -88,7 +90,7 @@ private:
bool isNative( QString nncDataType ) const;
private:
std::vector<RigConnection> m_connections;
RigConnectionContainer m_connections;
size_t m_nativeConnectionCount;
std::map<QString, std::vector<std::vector<double>>> m_connectionResults;
std::map<RigEclipseResultAddress, QString> m_resultAddrToNNCDataType;

View File

@ -25,11 +25,48 @@
//--------------------------------------------------------------------------------------------------
RigConnection::RigConnection()
: m_c1GlobIdx( cvf::UNDEFINED_SIZE_T )
, m_c1Face( cvf::StructGridInterface::NO_FACE )
, m_c2GlobIdx( cvf::UNDEFINED_SIZE_T )
, m_c1Face( cvf::StructGridInterface::NO_FACE )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigConnection::RigConnection( size_t c1GlobIdx,
size_t c2GlobIdx,
cvf::StructGridInterface::FaceType c1Face,
const std::vector<cvf::Vec3d>& polygon )
: m_c1GlobIdx( c1GlobIdx )
, m_c2GlobIdx( c2GlobIdx )
, m_c1Face( c1Face )
, m_polygon( polygon )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigConnection::RigConnection( const RigConnection& rhs )
: m_c1GlobIdx( rhs.m_c1GlobIdx )
, m_c2GlobIdx( rhs.m_c2GlobIdx )
, m_c1Face( rhs.m_c1Face )
, m_polygon( rhs.m_polygon )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigConnection& RigConnection::operator=( RigConnection& rhs )
{
m_c1GlobIdx = rhs.m_c1GlobIdx;
m_c2GlobIdx = rhs.m_c2GlobIdx;
m_c1Face = rhs.m_c1Face;
m_polygon = rhs.m_polygon;
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -37,3 +74,95 @@ bool RigConnection::hasCommonArea() const
{
return m_polygon.size() > 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigConnection::operator<( const RigConnection& other ) const
{
if ( m_c1GlobIdx != other.m_c1GlobIdx )
{
return m_c1GlobIdx < other.m_c1GlobIdx;
}
return ( m_c2GlobIdx < other.m_c2GlobIdx );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigConnection RigConnectionContainer::operator[]( size_t i ) const
{
const auto& globIndices = m_globalIndices[i];
return RigConnection( globIndices.first, globIndices.second, m_faces[i], m_polygons[i] );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<size_t, size_t>& RigConnectionContainer::indexPair( size_t i )
{
return m_globalIndices[i];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::StructGridInterface::FaceType& RigConnectionContainer::face( size_t i )
{
return m_faces[i];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d>& RigConnectionContainer::polygon( size_t i )
{
return m_polygons[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 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigConnectionContainer::insert( 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() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigConnectionContainer::size() const
{
return m_globalIndices.size();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigConnectionContainer::clear()
{
m_globalIndices.clear();
m_faces.clear();
m_polygons.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigConnectionContainer::empty() const
{
return m_globalIndices.empty();
}

View File

@ -21,6 +21,7 @@
#include "cvfStructGrid.h"
#include "cvfVector3.h"
#include <deque>
#include <vector>
//--------------------------------------------------------------------------------------------------
@ -30,12 +31,39 @@ class RigConnection
{
public:
RigConnection();
RigConnection( size_t c1GlobIdx,
size_t c2GlobIdx,
cvf::StructGridInterface::FaceType c1Face,
const std::vector<cvf::Vec3d>& polygon );
RigConnection( const RigConnection& rhs );
bool hasCommonArea() const;
RigConnection& operator=( RigConnection& rhs );
bool operator<( const RigConnection& other ) const;
bool hasCommonArea() const;
size_t m_c1GlobIdx;
cvf::StructGridInterface::FaceType m_c1Face;
size_t m_c2GlobIdx;
std::vector<cvf::Vec3d> m_polygon;
cvf::StructGridInterface::FaceType m_c1Face;
std::vector<cvf::Vec3d> m_polygon;
};
class RigConnectionContainer
{
public:
RigConnection operator[]( size_t i ) const;
std::pair<size_t, size_t>& indexPair( size_t i );
cvf::StructGridInterface::FaceType& face( size_t i );
std::vector<cvf::Vec3d>& polygon( size_t i );
void push_back( const RigConnection& connection );
void insert( const RigConnectionContainer& other );
size_t size() const;
void clear();
bool empty() const;
private:
std::vector<std::pair<size_t, size_t>> m_globalIndices;
std::vector<cvf::StructGridInterface::FaceType> m_faces;
std::vector<std::vector<cvf::Vec3d>> m_polygons;
};

View File

@ -100,8 +100,8 @@ RigNumberOfFloodedPoreVolumesCalculator::RigNumberOfFloodedPoreVolumesCalculator
std::vector<const std::vector<double>*> flowrateJatAllTimeSteps;
std::vector<const std::vector<double>*> flowrateKatAllTimeSteps;
RigNNCData* nncData = eclipseCaseData->mainGrid()->nncData();
const std::vector<RigConnection> connections = nncData->connections();
RigNNCData* nncData = eclipseCaseData->mainGrid()->nncData();
const RigConnectionContainer connections = nncData->connections();
progress.incrementProgress();
@ -200,7 +200,7 @@ void RigNumberOfFloodedPoreVolumesCalculator::calculate( RigMainGrid*
std::vector<const std::vector<double>*> flowrateIatAllTimeSteps,
std::vector<const std::vector<double>*> flowrateJatAllTimeSteps,
std::vector<const std::vector<double>*> flowrateKatAllTimeSteps,
const std::vector<RigConnection>& connections,
const RigConnectionContainer& connections,
std::vector<const std::vector<double>*> flowrateNNCatAllTimeSteps,
std::vector<std::vector<double>> summedTracersAtAllTimesteps )
{
@ -294,11 +294,11 @@ void RigNumberOfFloodedPoreVolumesCalculator::calculate( RigMainGrid*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigNumberOfFloodedPoreVolumesCalculator::distributeNNCflow( const std::vector<RigConnection>& connections,
RimEclipseCase* caseToApply,
const std::vector<double>& summedTracerValues,
const std::vector<double>* flowrateNNC,
std::vector<double>& flowrateIntoCell )
void RigNumberOfFloodedPoreVolumesCalculator::distributeNNCflow( const RigConnectionContainer& connections,
RimEclipseCase* caseToApply,
const std::vector<double>& summedTracerValues,
const std::vector<double>* flowrateNNC,
std::vector<double>& flowrateIntoCell )
{
RigActiveCellInfo* actCellInfo =
caseToApply->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );

View File

@ -18,13 +18,15 @@
#pragma once
#include "RigNncConnection.h"
#include <QString>
#include <cstddef>
#include <deque>
#include <vector>
class RimEclipseCase;
class RigMainGrid;
class RigConnection;
//==================================================================================================
///
@ -48,15 +50,15 @@ private:
std::vector<const std::vector<double>*> flowrateIatAllTimeSteps,
std::vector<const std::vector<double>*> flowrateJatAllTimeSteps,
std::vector<const std::vector<double>*> flowrateKatAllTimeSteps,
const std::vector<RigConnection>& connections,
const RigConnectionContainer& connections,
std::vector<const std::vector<double>*> flowrateNNCatAllTimeSteps,
std::vector<std::vector<double>> summedTracersAtAllTimesteps );
void distributeNNCflow( const std::vector<RigConnection>& connections,
RimEclipseCase* caseToApply,
const std::vector<double>& summedTracerValues,
const std::vector<double>* flowrateNNC,
std::vector<double>& flowrateIntoCell );
void distributeNNCflow( const RigConnectionContainer& connections,
RimEclipseCase* caseToApply,
const std::vector<double>& summedTracerValues,
const std::vector<double>* flowrateNNC,
std::vector<double>& flowrateIntoCell );
void distributeNeighbourCellFlow( RigMainGrid* mainGrid,
RimEclipseCase* caseToApply,

View File

@ -533,7 +533,7 @@ void RigReservoirBuilderMock::addFaults( RigEclipseCaseData* eclipseCase )
grid->setFaults( faults );
// NNCs
std::vector<RigConnection> nncConnections;
RigConnectionContainer nncConnections;
{
size_t i1 = 2;
size_t j1 = 2;
@ -579,14 +579,14 @@ void RigReservoirBuilderMock::enableWellData( bool enableWellData )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirBuilderMock::addNnc( RigMainGrid* grid,
size_t i1,
size_t j1,
size_t k1,
size_t i2,
size_t j2,
size_t k2,
std::vector<RigConnection>& nncConnections )
void RigReservoirBuilderMock::addNnc( RigMainGrid* grid,
size_t i1,
size_t j1,
size_t k1,
size_t i2,
size_t j2,
size_t k2,
RigConnectionContainer& nncConnections )
{
size_t c1GlobalIndex = grid->cellIndexFromIJK( i1, j1, k1 );
size_t c2GlobalIndex = grid->cellIndexFromIJK( i2, j2, k2 );

View File

@ -20,13 +20,16 @@
#pragma once
#include "RigNncConnection.h"
#include "cvfArray.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include <deque>
class RigEclipseCaseData;
class RigMainGrid;
class RigConnection;
class RigGridBase;
class RigCell;
@ -76,14 +79,14 @@ public:
private:
void addFaults( RigEclipseCaseData* eclipseCase );
static void addNnc( RigMainGrid* grid,
size_t i1,
size_t j1,
size_t k1,
size_t i2,
size_t j2,
size_t k2,
std::vector<RigConnection>& nncConnections );
static void addNnc( RigMainGrid* grid,
size_t i1,
size_t j1,
size_t k1,
size_t i2,
size_t j2,
size_t k2,
RigConnectionContainer& nncConnections );
void addWellData( RigEclipseCaseData* eclipseCase, RigGridBase* grid );
static void appendCells( size_t nodeStartIndex, size_t cellCount, RigGridBase* hostGrid, std::vector<RigCell>& cells );

View File

@ -69,8 +69,10 @@ public:
socketStream << (quint64)connectionCount;
for ( const RigConnection& connection : mainGrid->nncData()->connections() )
for ( size_t i = 0; i < mainGrid->nncData()->connections().size(); ++i )
{
RigConnection connection = mainGrid->nncData()->connections()[i];
const RigCell& cell1 = mainGrid->globalCellArray()[connection.m_c1GlobIdx];
const RigCell& cell2 = mainGrid->globalCellArray()[connection.m_c2GlobIdx];

View File

@ -56,7 +56,7 @@ target_include_directories(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES})
if (MSVC)
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W4 /wd4127")
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W3 /wd4127")
endif()
source_group("" FILES ${PROJECT_FILES})

View File

@ -60,7 +60,7 @@ target_link_libraries ( ${PROJECT_NAME}
)
if (MSVC)
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W4 /wd4100 /wd4127")
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W3 /wd4100 /wd4127")
endif()
source_group("" FILES ${PROJECT_FILES})

View File

@ -119,7 +119,7 @@ if (NOT ERT_WINDOWS)
endif()
if (MSVC)
add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4996" )
add_definitions( "/W4 /D_CRT_SECURE_NO_WARNINGS /wd4996" )
endif()