mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5915 improve performance of NNC computation and limit to active cells
This commit is contained in:
parent
3d2ac4b573
commit
f199297f12
@ -396,9 +396,9 @@ if (MSVC)
|
|||||||
# warning C4005: Macro redefinition for math constants (M_PI, M_SQRT2 etc)
|
# warning C4005: Macro redefinition for math constants (M_PI, M_SQRT2 etc)
|
||||||
|
|
||||||
# If possible, the following command is supposed to be the final target
|
# 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)
|
if (CMAKE_CXX_COMPILER_VERSION LESS_EQUAL 19.14)
|
||||||
# The following warning is generated over 800 times from a qwt header only using VS2015
|
# The following warning is generated over 800 times from a qwt header only using VS2015
|
||||||
# Disabling temporarily
|
# Disabling temporarily
|
||||||
|
@ -723,8 +723,8 @@ void RifReaderEclipseOutput::transferStaticNNCData( const ecl_grid_type* mainEcl
|
|||||||
if ( numNNC > 0 )
|
if ( numNNC > 0 )
|
||||||
{
|
{
|
||||||
// Transform to our own data structures
|
// Transform to our own data structures
|
||||||
std::vector<RigConnection> nncConnections;
|
RigConnectionContainer nncConnections;
|
||||||
std::vector<double> transmissibilityValuesTemp;
|
std::vector<double> transmissibilityValuesTemp;
|
||||||
|
|
||||||
const double* transValues = ecl_nnc_data_get_values( tran_data );
|
const double* transValues = ecl_nnc_data_get_values( tran_data );
|
||||||
|
|
||||||
@ -1289,7 +1289,7 @@ size_t localGridCellIndexFromErtConnection( const RigGridBase* grid,
|
|||||||
cellK = 0;
|
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() ) )
|
if ( cellK >= static_cast<int>( grid->cellCountK() ) )
|
||||||
{
|
{
|
||||||
int maxCellK = static_cast<int>( grid->cellCountK() );
|
int maxCellK = static_cast<int>( grid->cellCountK() );
|
||||||
|
@ -26,7 +26,7 @@ def test_10kSync(rips_instance, initialize_test):
|
|||||||
assert(NNCProperties_pb2.NNCPropertyType.Value('NNC_GENERATED') == properties[2].property_type)
|
assert(NNCProperties_pb2.NNCPropertyType.Value('NNC_GENERATED') == properties[2].property_type)
|
||||||
|
|
||||||
nnc_connections = case.nnc_connections()
|
nnc_connections = case.nnc_connections()
|
||||||
assert(len(nnc_connections) == 84759)
|
assert(len(nnc_connections) == 3416)
|
||||||
|
|
||||||
connection = nnc_connections[0]
|
connection = nnc_connections[0]
|
||||||
assert(connection.cell1.i == 33)
|
assert(connection.cell1.i == 33)
|
||||||
|
@ -88,8 +88,8 @@ rips::Vec3i* createConnectionVec3i( const RigCell& cell )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
grpc::Status RiaNNCConnectionsStateHandler::assignReply( rips::NNCConnections* reply )
|
grpc::Status RiaNNCConnectionsStateHandler::assignReply( rips::NNCConnections* reply )
|
||||||
{
|
{
|
||||||
RigMainGrid* mainGrid = m_eclipseCase->eclipseCaseData()->mainGrid();
|
RigMainGrid* mainGrid = m_eclipseCase->eclipseCaseData()->mainGrid();
|
||||||
std::vector<RigConnection> connections = mainGrid->nncData()->connections();
|
const RigConnectionContainer& connections = mainGrid->nncData()->connections();
|
||||||
|
|
||||||
size_t connectionCount = connections.size();
|
size_t connectionCount = connections.size();
|
||||||
const size_t packageSize = RiaGrpcServiceInterface::numberOfDataUnitsInPackage( sizeof( rips::NNCConnection ) );
|
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 );
|
reply->mutable_connections()->Reserve( (int)packageSize );
|
||||||
for ( ; indexInPackage < packageSize && m_currentIdx < connectionCount; ++indexInPackage )
|
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& cell1 = mainGrid->globalCellArray()[connection.m_c1GlobIdx];
|
||||||
const RigCell& cell2 = mainGrid->globalCellArray()[connection.m_c2GlobIdx];
|
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 )
|
grpc::Status RiaNNCValuesStateHandler::assignReply( rips::NNCValues* reply )
|
||||||
{
|
{
|
||||||
RigMainGrid* mainGrid = m_eclipseCase->eclipseCaseData()->mainGrid();
|
RigMainGrid* mainGrid = m_eclipseCase->eclipseCaseData()->mainGrid();
|
||||||
std::vector<RigConnection> connections = mainGrid->nncData()->connections();
|
auto connections = mainGrid->nncData()->connections();
|
||||||
|
|
||||||
QString propertyName = QString::fromStdString( m_request->property_name() );
|
QString propertyName = QString::fromStdString( m_request->property_name() );
|
||||||
RigNNCData::NNCResultType propertyType = static_cast<RigNNCData::NNCResultType>( m_request->property_type() );
|
RigNNCData::NNCResultType propertyType = static_cast<RigNNCData::NNCResultType>( m_request->property_type() );
|
||||||
@ -496,31 +496,32 @@ std::vector<RiaGrpcCallbackInterface*> RiaGrpcNNCPropertiesService::createCallba
|
|||||||
|
|
||||||
std::vector<RiaGrpcCallbackInterface*> callbacks;
|
std::vector<RiaGrpcCallbackInterface*> callbacks;
|
||||||
callbacks =
|
callbacks =
|
||||||
{new RiaGrpcUnaryCallback<Self, CaseRequest, AvailableNNCProperties>( this,
|
{ new RiaGrpcUnaryCallback<Self, CaseRequest, AvailableNNCProperties>( this,
|
||||||
&Self::GetAvailableNNCProperties,
|
&Self::GetAvailableNNCProperties,
|
||||||
&Self::RequestGetAvailableNNCProperties ),
|
&Self::RequestGetAvailableNNCProperties ),
|
||||||
new RiaGrpcServerToClientStreamCallback<Self,
|
new RiaGrpcServerToClientStreamCallback<Self,
|
||||||
CaseRequest,
|
CaseRequest,
|
||||||
rips::NNCConnections,
|
rips::NNCConnections,
|
||||||
RiaNNCConnectionsStateHandler>( this,
|
RiaNNCConnectionsStateHandler>( this,
|
||||||
&Self::GetNNCConnections,
|
&Self::GetNNCConnections,
|
||||||
&Self::RequestGetNNCConnections,
|
&Self::RequestGetNNCConnections,
|
||||||
new RiaNNCConnectionsStateHandler ),
|
new RiaNNCConnectionsStateHandler ),
|
||||||
new RiaGrpcServerToClientStreamCallback<Self,
|
new RiaGrpcServerToClientStreamCallback<Self,
|
||||||
NNCValuesRequest,
|
NNCValuesRequest,
|
||||||
rips::NNCValues,
|
rips::NNCValues,
|
||||||
RiaNNCValuesStateHandler>( this,
|
RiaNNCValuesStateHandler>( this,
|
||||||
&Self::GetNNCValues,
|
&Self::GetNNCValues,
|
||||||
&Self::RequestGetNNCValues,
|
&Self::RequestGetNNCValues,
|
||||||
new RiaNNCValuesStateHandler ),
|
new RiaNNCValuesStateHandler ),
|
||||||
|
|
||||||
new RiaGrpcClientToServerStreamCallback<Self,
|
new RiaGrpcClientToServerStreamCallback<Self,
|
||||||
NNCValuesChunk,
|
NNCValuesChunk,
|
||||||
ClientToServerStreamReply,
|
ClientToServerStreamReply,
|
||||||
RiaNNCInputValuesStateHandler>( this,
|
RiaNNCInputValuesStateHandler>( this,
|
||||||
&Self::SetNNCValues,
|
&Self::SetNNCValues,
|
||||||
&Self::RequestSetNNCValues,
|
&Self::RequestSetNNCValues,
|
||||||
new RiaNNCInputValuesStateHandler( true ) )};
|
new RiaNNCInputValuesStateHandler(
|
||||||
|
true ) ) };
|
||||||
|
|
||||||
return callbacks;
|
return callbacks;
|
||||||
}
|
}
|
||||||
|
@ -266,8 +266,8 @@ void RimFaultInViewCollection::syncronizeFaults()
|
|||||||
// NNCs
|
// NNCs
|
||||||
this->noCommonAreaNnncCollection()->noCommonAreaNncs().deleteAllChildObjects();
|
this->noCommonAreaNnncCollection()->noCommonAreaNncs().deleteAllChildObjects();
|
||||||
|
|
||||||
RigMainGrid* mainGrid = parentView()->mainGrid();
|
RigMainGrid* mainGrid = parentView()->mainGrid();
|
||||||
const std::vector<RigConnection>& nncConnections = mainGrid->nncData()->connections();
|
const RigConnectionContainer& nncConnections = mainGrid->nncData()->connections();
|
||||||
for ( size_t connIndex = 0; connIndex < nncConnections.size(); connIndex++ )
|
for ( size_t connIndex = 0; connIndex < nncConnections.size(); connIndex++ )
|
||||||
{
|
{
|
||||||
if ( !nncConnections[connIndex].hasCommonArea() )
|
if ( !nncConnections[connIndex].hasCommonArea() )
|
||||||
|
@ -2303,7 +2303,7 @@ void RigCaseCellResultsData::computeNncCombRiTrans()
|
|||||||
bool isFaceNormalsOutwards = m_ownerMainGrid->isFaceNormalsOutwards();
|
bool isFaceNormalsOutwards = m_ownerMainGrid->isFaceNormalsOutwards();
|
||||||
|
|
||||||
// NNC calculation
|
// 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++ )
|
for ( size_t connIdx = 0; connIdx < nncConnections.size(); connIdx++ )
|
||||||
{
|
{
|
||||||
size_t nativeResvCellIndex = nncConnections[connIdx].m_c1GlobIdx;
|
size_t nativeResvCellIndex = nncConnections[connIdx].m_c1GlobIdx;
|
||||||
@ -2665,7 +2665,7 @@ void RigCaseCellResultsData::computeNncCombRiTRANSbyArea()
|
|||||||
|
|
||||||
if ( transResults->size() != riAreaNormTransResults.size() ) return;
|
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 )
|
for ( size_t nncConIdx = 0; nncConIdx < riAreaNormTransResults.size(); ++nncConIdx )
|
||||||
{
|
{
|
||||||
@ -3130,7 +3130,7 @@ void RigCaseCellResultsData::computeAllanResults( RigCaseCellResultsData* cellRe
|
|||||||
formationCount = cellResultsData->activeFormationNames()->formationNames().size();
|
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;
|
std::map<std::pair<int, int>, int> formationCombinationToCategory;
|
||||||
for ( size_t i = 0; i < nncConnections.size(); i++ )
|
for ( size_t i = 0; i < nncConnections.size(); i++ )
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "RigCellFaceGeometryTools.h"
|
#include "RigCellFaceGeometryTools.h"
|
||||||
|
|
||||||
|
#include "RigActiveCellInfo.h"
|
||||||
#include "RigCell.h"
|
#include "RigCell.h"
|
||||||
#include "RigMainGrid.h"
|
#include "RigMainGrid.h"
|
||||||
#include "RigNncConnection.h"
|
#include "RigNncConnection.h"
|
||||||
@ -28,6 +29,8 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include <omp.h>
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -40,7 +43,7 @@ cvf::StructGridInterface::FaceType
|
|||||||
{
|
{
|
||||||
// Try to find the shared face
|
// 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() )
|
if ( c1.hostGrid() == c2.hostGrid() )
|
||||||
{
|
{
|
||||||
@ -116,55 +119,42 @@ cvf::StructGridInterface::FaceType
|
|||||||
return cvf::StructGridInterface::NO_FACE;
|
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,
|
RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMainGrid* mainGrid,
|
||||||
const std::vector<RigConnection>& nativeConnections )
|
const RigConnectionContainer& nativeConnections,
|
||||||
|
const RigActiveCellInfo* activeCellInfo )
|
||||||
{
|
{
|
||||||
// Compute Non-Neighbor Connections (NNC) not reported by Eclipse. NNCs with zero transmissibility are not reported
|
// 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
|
// 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.
|
// 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:
|
RigConnection c = nativeConnections[i];
|
||||||
CellPair( size_t globalIdx1, size_t globalIdx2 )
|
nativeCellPairs.emplace( c.m_c1GlobIdx, c.m_c2GlobIdx );
|
||||||
{
|
|
||||||
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 ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( nativeConnections.size() != nativeCellPairs.size() )
|
if ( nativeConnections.size() != nativeCellPairs.size() )
|
||||||
@ -175,164 +165,181 @@ std::vector<RigConnection> RigCellFaceGeometryTools::computeOtherNncs( const Rig
|
|||||||
qDebug() << message;
|
qDebug() << message;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<CellPair> otherCellPairs;
|
|
||||||
|
|
||||||
const cvf::Collection<RigFault>& faults = mainGrid->faults();
|
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 RigFault* fault = faults.at( faultIdx );
|
||||||
|
|
||||||
const std::vector<RigFault::FaultFace>& faultFaces = fault->faultFaces();
|
const std::vector<RigFault::FaultFace>& faultFaces = fault->faultFaces();
|
||||||
|
|
||||||
#pragma omp parallel for
|
#pragma omp parallel
|
||||||
for ( int faceIdx = 0; faceIdx < static_cast<int>( faultFaces.size() ); faceIdx++ )
|
|
||||||
{
|
{
|
||||||
const RigFault::FaultFace& f = faultFaces[faceIdx];
|
RigConnectionContainer threadConnections;
|
||||||
|
#pragma omp for
|
||||||
size_t sourceReservoirCellIndex = f.m_nativeReservoirCellIndex;
|
for ( int faceIdx = 0; faceIdx < static_cast<int>( faultFaces.size() ); faceIdx++ )
|
||||||
cvf::StructGridInterface::FaceType sourceCellFace = f.m_nativeFace;
|
|
||||||
|
|
||||||
if ( sourceReservoirCellIndex >= mainGrid->cellCount() )
|
|
||||||
{
|
{
|
||||||
continue;
|
const RigFault::FaultFace& f = faultFaces[faceIdx];
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<cvf::Vec3d>& mainGridNodes = mainGrid->nodes();
|
bool atLeastOneCellActive = !activeCellInfo ||
|
||||||
|
( activeCellInfo->isActive( f.m_nativeReservoirCellIndex ) ||
|
||||||
cvf::BoundingBox bb;
|
activeCellInfo->isActive( f.m_oppositeReservoirCellIndex ) );
|
||||||
std::array<size_t, 4> sourceFaceIndices;
|
if ( atLeastOneCellActive )
|
||||||
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 );
|
RigConnectionContainer faceConnections = extractConnectionsForFace( f, mainGrid, nativeCellPairs );
|
||||||
|
threadConnections.insert( faceConnections );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Merge together connections per thread
|
||||||
for ( size_t candidateCellIndex : closeCells )
|
assignThreadConnections( existingPairs, otherConnections, threadConnections );
|
||||||
{
|
} // end parallel region
|
||||||
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 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return otherConnections;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -18,15 +18,21 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "RigFault.h"
|
||||||
|
#include "RigNncConnection.h"
|
||||||
|
|
||||||
#include "cvfCollection.h"
|
#include "cvfCollection.h"
|
||||||
#include "cvfStructGrid.h"
|
#include "cvfStructGrid.h"
|
||||||
#include "cvfVector3.h"
|
#include "cvfVector3.h"
|
||||||
|
|
||||||
|
#include <deque>
|
||||||
|
#include <set>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
class RigActiveCellInfo;
|
||||||
class RigCell;
|
class RigCell;
|
||||||
class RigMainGrid;
|
class RigMainGrid;
|
||||||
class RigConnection;
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
@ -40,9 +46,13 @@ public:
|
|||||||
std::vector<size_t>* connectionPolygon,
|
std::vector<size_t>* connectionPolygon,
|
||||||
std::vector<cvf::Vec3d>* connectionIntersections );
|
std::vector<cvf::Vec3d>* connectionIntersections );
|
||||||
|
|
||||||
static std::vector<RigConnection> computeOtherNncs( const RigMainGrid* mainGrid,
|
static RigConnectionContainer computeOtherNncs( const RigMainGrid* mainGrid,
|
||||||
const std::vector<RigConnection>& nativeConnections );
|
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,
|
static std::vector<cvf::Vec3d> extractPolygon( const std::vector<cvf::Vec3d>& nativeNodes,
|
||||||
const std::vector<size_t>& connectionPolygon,
|
const std::vector<size_t>& connectionPolygon,
|
||||||
const std::vector<cvf::Vec3d>& connectionIntersections );
|
const std::vector<cvf::Vec3d>& connectionIntersections );
|
||||||
|
@ -556,7 +556,7 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->nncData()->computeCompleteSetOfNncs( this );
|
this->nncData()->computeCompleteSetOfNncs( this, activeCellInfo );
|
||||||
|
|
||||||
distributeNNCsToFaults();
|
distributeNNCsToFaults();
|
||||||
}
|
}
|
||||||
@ -566,7 +566,7 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RigMainGrid::distributeNNCsToFaults()
|
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 )
|
for ( size_t nncIdx = 0; nncIdx < nncs.size(); ++nncIdx )
|
||||||
{
|
{
|
||||||
// Find the fault for each side of the nnc
|
// Find the fault for each side of the nnc
|
||||||
|
@ -55,9 +55,9 @@ void RigNNCData::processNativeConnections( const RigMainGrid& mainGrid )
|
|||||||
{
|
{
|
||||||
// Found an overlap polygon. Store data about connection
|
// 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 );
|
RigCellFaceGeometryTools::extractPolygon( mainGrid.nodes(), connectionPolygon, connectionIntersections );
|
||||||
|
|
||||||
// Add to search map, possibly not needed
|
// 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();
|
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() )
|
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
|
// Transmissibility values from Eclipse has been read into propertyNameCombTrans in
|
||||||
// RifReaderEclipseOutput::transferStaticNNCData(). Initialize computed NNCs with zero transmissibility
|
// 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;
|
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;
|
return m_connections;
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,11 @@
|
|||||||
#include "cvfVector3.h"
|
#include "cvfVector3.h"
|
||||||
|
|
||||||
#include <cmath> // Needed for HUGE_VAL on Linux
|
#include <cmath> // Needed for HUGE_VAL on Linux
|
||||||
|
#include <deque>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
class RigActiveCellInfo;
|
||||||
class RigMainGrid;
|
class RigMainGrid;
|
||||||
class RigCell;
|
class RigCell;
|
||||||
class RigEclipseResultAddress;
|
class RigEclipseResultAddress;
|
||||||
@ -48,12 +50,12 @@ public:
|
|||||||
RigNNCData();
|
RigNNCData();
|
||||||
|
|
||||||
void processNativeConnections( const RigMainGrid& mainGrid );
|
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;
|
size_t nativeConnectionCount() const;
|
||||||
|
|
||||||
const std::vector<RigConnection>& connections() const;
|
const RigConnectionContainer& connections() const;
|
||||||
|
|
||||||
std::vector<double>& makeStaticConnectionScalarResult( QString nncDataType );
|
std::vector<double>& makeStaticConnectionScalarResult( QString nncDataType );
|
||||||
const std::vector<double>* staticConnectionScalarResult( const RigEclipseResultAddress& resVarAddr ) const;
|
const std::vector<double>* staticConnectionScalarResult( const RigEclipseResultAddress& resVarAddr ) const;
|
||||||
@ -88,7 +90,7 @@ private:
|
|||||||
bool isNative( QString nncDataType ) const;
|
bool isNative( QString nncDataType ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<RigConnection> m_connections;
|
RigConnectionContainer m_connections;
|
||||||
size_t m_nativeConnectionCount;
|
size_t m_nativeConnectionCount;
|
||||||
std::map<QString, std::vector<std::vector<double>>> m_connectionResults;
|
std::map<QString, std::vector<std::vector<double>>> m_connectionResults;
|
||||||
std::map<RigEclipseResultAddress, QString> m_resultAddrToNNCDataType;
|
std::map<RigEclipseResultAddress, QString> m_resultAddrToNNCDataType;
|
||||||
|
@ -25,11 +25,48 @@
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RigConnection::RigConnection()
|
RigConnection::RigConnection()
|
||||||
: m_c1GlobIdx( cvf::UNDEFINED_SIZE_T )
|
: m_c1GlobIdx( cvf::UNDEFINED_SIZE_T )
|
||||||
, m_c1Face( cvf::StructGridInterface::NO_FACE )
|
|
||||||
, m_c2GlobIdx( cvf::UNDEFINED_SIZE_T )
|
, 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;
|
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();
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "cvfStructGrid.h"
|
#include "cvfStructGrid.h"
|
||||||
#include "cvfVector3.h"
|
#include "cvfVector3.h"
|
||||||
|
|
||||||
|
#include <deque>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -30,12 +31,39 @@ class RigConnection
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RigConnection();
|
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;
|
size_t m_c1GlobIdx;
|
||||||
cvf::StructGridInterface::FaceType m_c1Face;
|
|
||||||
size_t m_c2GlobIdx;
|
size_t m_c2GlobIdx;
|
||||||
|
cvf::StructGridInterface::FaceType m_c1Face;
|
||||||
std::vector<cvf::Vec3d> m_polygon;
|
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;
|
||||||
};
|
};
|
||||||
|
@ -100,8 +100,8 @@ RigNumberOfFloodedPoreVolumesCalculator::RigNumberOfFloodedPoreVolumesCalculator
|
|||||||
std::vector<const std::vector<double>*> flowrateJatAllTimeSteps;
|
std::vector<const std::vector<double>*> flowrateJatAllTimeSteps;
|
||||||
std::vector<const std::vector<double>*> flowrateKatAllTimeSteps;
|
std::vector<const std::vector<double>*> flowrateKatAllTimeSteps;
|
||||||
|
|
||||||
RigNNCData* nncData = eclipseCaseData->mainGrid()->nncData();
|
RigNNCData* nncData = eclipseCaseData->mainGrid()->nncData();
|
||||||
const std::vector<RigConnection> connections = nncData->connections();
|
const RigConnectionContainer connections = nncData->connections();
|
||||||
|
|
||||||
progress.incrementProgress();
|
progress.incrementProgress();
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ void RigNumberOfFloodedPoreVolumesCalculator::calculate( RigMainGrid*
|
|||||||
std::vector<const std::vector<double>*> flowrateIatAllTimeSteps,
|
std::vector<const std::vector<double>*> flowrateIatAllTimeSteps,
|
||||||
std::vector<const std::vector<double>*> flowrateJatAllTimeSteps,
|
std::vector<const std::vector<double>*> flowrateJatAllTimeSteps,
|
||||||
std::vector<const std::vector<double>*> flowrateKatAllTimeSteps,
|
std::vector<const std::vector<double>*> flowrateKatAllTimeSteps,
|
||||||
const std::vector<RigConnection>& connections,
|
const RigConnectionContainer& connections,
|
||||||
std::vector<const std::vector<double>*> flowrateNNCatAllTimeSteps,
|
std::vector<const std::vector<double>*> flowrateNNCatAllTimeSteps,
|
||||||
std::vector<std::vector<double>> summedTracersAtAllTimesteps )
|
std::vector<std::vector<double>> summedTracersAtAllTimesteps )
|
||||||
{
|
{
|
||||||
@ -294,11 +294,11 @@ void RigNumberOfFloodedPoreVolumesCalculator::calculate( RigMainGrid*
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RigNumberOfFloodedPoreVolumesCalculator::distributeNNCflow( const std::vector<RigConnection>& connections,
|
void RigNumberOfFloodedPoreVolumesCalculator::distributeNNCflow( const RigConnectionContainer& connections,
|
||||||
RimEclipseCase* caseToApply,
|
RimEclipseCase* caseToApply,
|
||||||
const std::vector<double>& summedTracerValues,
|
const std::vector<double>& summedTracerValues,
|
||||||
const std::vector<double>* flowrateNNC,
|
const std::vector<double>* flowrateNNC,
|
||||||
std::vector<double>& flowrateIntoCell )
|
std::vector<double>& flowrateIntoCell )
|
||||||
{
|
{
|
||||||
RigActiveCellInfo* actCellInfo =
|
RigActiveCellInfo* actCellInfo =
|
||||||
caseToApply->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
caseToApply->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
||||||
|
@ -18,13 +18,15 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "RigNncConnection.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <deque>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class RimEclipseCase;
|
class RimEclipseCase;
|
||||||
class RigMainGrid;
|
class RigMainGrid;
|
||||||
class RigConnection;
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
@ -48,15 +50,15 @@ private:
|
|||||||
std::vector<const std::vector<double>*> flowrateIatAllTimeSteps,
|
std::vector<const std::vector<double>*> flowrateIatAllTimeSteps,
|
||||||
std::vector<const std::vector<double>*> flowrateJatAllTimeSteps,
|
std::vector<const std::vector<double>*> flowrateJatAllTimeSteps,
|
||||||
std::vector<const std::vector<double>*> flowrateKatAllTimeSteps,
|
std::vector<const std::vector<double>*> flowrateKatAllTimeSteps,
|
||||||
const std::vector<RigConnection>& connections,
|
const RigConnectionContainer& connections,
|
||||||
std::vector<const std::vector<double>*> flowrateNNCatAllTimeSteps,
|
std::vector<const std::vector<double>*> flowrateNNCatAllTimeSteps,
|
||||||
std::vector<std::vector<double>> summedTracersAtAllTimesteps );
|
std::vector<std::vector<double>> summedTracersAtAllTimesteps );
|
||||||
|
|
||||||
void distributeNNCflow( const std::vector<RigConnection>& connections,
|
void distributeNNCflow( const RigConnectionContainer& connections,
|
||||||
RimEclipseCase* caseToApply,
|
RimEclipseCase* caseToApply,
|
||||||
const std::vector<double>& summedTracerValues,
|
const std::vector<double>& summedTracerValues,
|
||||||
const std::vector<double>* flowrateNNC,
|
const std::vector<double>* flowrateNNC,
|
||||||
std::vector<double>& flowrateIntoCell );
|
std::vector<double>& flowrateIntoCell );
|
||||||
|
|
||||||
void distributeNeighbourCellFlow( RigMainGrid* mainGrid,
|
void distributeNeighbourCellFlow( RigMainGrid* mainGrid,
|
||||||
RimEclipseCase* caseToApply,
|
RimEclipseCase* caseToApply,
|
||||||
|
@ -533,7 +533,7 @@ void RigReservoirBuilderMock::addFaults( RigEclipseCaseData* eclipseCase )
|
|||||||
grid->setFaults( faults );
|
grid->setFaults( faults );
|
||||||
|
|
||||||
// NNCs
|
// NNCs
|
||||||
std::vector<RigConnection> nncConnections;
|
RigConnectionContainer nncConnections;
|
||||||
{
|
{
|
||||||
size_t i1 = 2;
|
size_t i1 = 2;
|
||||||
size_t j1 = 2;
|
size_t j1 = 2;
|
||||||
@ -579,14 +579,14 @@ void RigReservoirBuilderMock::enableWellData( bool enableWellData )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RigReservoirBuilderMock::addNnc( RigMainGrid* grid,
|
void RigReservoirBuilderMock::addNnc( RigMainGrid* grid,
|
||||||
size_t i1,
|
size_t i1,
|
||||||
size_t j1,
|
size_t j1,
|
||||||
size_t k1,
|
size_t k1,
|
||||||
size_t i2,
|
size_t i2,
|
||||||
size_t j2,
|
size_t j2,
|
||||||
size_t k2,
|
size_t k2,
|
||||||
std::vector<RigConnection>& nncConnections )
|
RigConnectionContainer& nncConnections )
|
||||||
{
|
{
|
||||||
size_t c1GlobalIndex = grid->cellIndexFromIJK( i1, j1, k1 );
|
size_t c1GlobalIndex = grid->cellIndexFromIJK( i1, j1, k1 );
|
||||||
size_t c2GlobalIndex = grid->cellIndexFromIJK( i2, j2, k2 );
|
size_t c2GlobalIndex = grid->cellIndexFromIJK( i2, j2, k2 );
|
||||||
|
@ -20,13 +20,16 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "RigNncConnection.h"
|
||||||
|
|
||||||
#include "cvfArray.h"
|
#include "cvfArray.h"
|
||||||
#include "cvfObject.h"
|
#include "cvfObject.h"
|
||||||
#include "cvfVector3.h"
|
#include "cvfVector3.h"
|
||||||
|
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
class RigEclipseCaseData;
|
class RigEclipseCaseData;
|
||||||
class RigMainGrid;
|
class RigMainGrid;
|
||||||
class RigConnection;
|
|
||||||
class RigGridBase;
|
class RigGridBase;
|
||||||
class RigCell;
|
class RigCell;
|
||||||
|
|
||||||
@ -76,14 +79,14 @@ public:
|
|||||||
private:
|
private:
|
||||||
void addFaults( RigEclipseCaseData* eclipseCase );
|
void addFaults( RigEclipseCaseData* eclipseCase );
|
||||||
|
|
||||||
static void addNnc( RigMainGrid* grid,
|
static void addNnc( RigMainGrid* grid,
|
||||||
size_t i1,
|
size_t i1,
|
||||||
size_t j1,
|
size_t j1,
|
||||||
size_t k1,
|
size_t k1,
|
||||||
size_t i2,
|
size_t i2,
|
||||||
size_t j2,
|
size_t j2,
|
||||||
size_t k2,
|
size_t k2,
|
||||||
std::vector<RigConnection>& nncConnections );
|
RigConnectionContainer& nncConnections );
|
||||||
void addWellData( RigEclipseCaseData* eclipseCase, RigGridBase* grid );
|
void addWellData( RigEclipseCaseData* eclipseCase, RigGridBase* grid );
|
||||||
static void appendCells( size_t nodeStartIndex, size_t cellCount, RigGridBase* hostGrid, std::vector<RigCell>& cells );
|
static void appendCells( size_t nodeStartIndex, size_t cellCount, RigGridBase* hostGrid, std::vector<RigCell>& cells );
|
||||||
|
|
||||||
|
@ -69,8 +69,10 @@ public:
|
|||||||
|
|
||||||
socketStream << (quint64)connectionCount;
|
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& cell1 = mainGrid->globalCellArray()[connection.m_c1GlobIdx];
|
||||||
const RigCell& cell2 = mainGrid->globalCellArray()[connection.m_c2GlobIdx];
|
const RigCell& cell2 = mainGrid->globalCellArray()[connection.m_c2GlobIdx];
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ target_include_directories(${PROJECT_NAME}
|
|||||||
target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES})
|
target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES})
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W4 /wd4127")
|
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W3 /wd4127")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
source_group("" FILES ${PROJECT_FILES})
|
source_group("" FILES ${PROJECT_FILES})
|
||||||
|
@ -60,7 +60,7 @@ target_link_libraries ( ${PROJECT_NAME}
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (MSVC)
|
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()
|
endif()
|
||||||
|
|
||||||
source_group("" FILES ${PROJECT_FILES})
|
source_group("" FILES ${PROJECT_FILES})
|
||||||
|
2
ThirdParty/Ert/CMakeLists.txt
vendored
2
ThirdParty/Ert/CMakeLists.txt
vendored
@ -119,7 +119,7 @@ if (NOT ERT_WINDOWS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4996" )
|
add_definitions( "/W4 /D_CRT_SECURE_NO_WARNINGS /wd4996" )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user