Refactored some code to make it possible to parallelise

This commit is contained in:
Gaute Lindkvist 2020-05-14 10:17:42 +02:00
parent de824f2543
commit c7851f0001
2 changed files with 136 additions and 97 deletions

View File

@ -448,11 +448,43 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo )
const std::vector<cvf::Vec3d>& vxs = m_mainGrid->nodes(); const std::vector<cvf::Vec3d>& vxs = m_mainGrid->nodes();
std::vector<RigFault::FaultFace>& unNamedFaultFaces = unNamedFault->faultFaces();
std::vector<RigFault::FaultFace>& unNamedFaultFacesInactive = unNamedFaultWithInactive->faultFaces();
for ( int gcIdx = 0; gcIdx < static_cast<int>( m_cells.size() ); ++gcIdx ) for ( int gcIdx = 0; gcIdx < static_cast<int>( m_cells.size() ); ++gcIdx )
{
addUnNamedFaultFaces( gcIdx,
activeCellInfo,
vxs,
unNamedFaultIdx,
unNamedFaultWithInactiveIdx,
unNamedFaultFaces,
unNamedFaultFacesInactive,
m_faultsPrCellAcc.p() );
}
if ( computeNncs )
{
this->nncData()->computeCompleteSetOfNncs( this, activeCellInfo, includeInactiveCells );
}
distributeNNCsToFaults();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigMainGrid::addUnNamedFaultFaces( int gcIdx,
const RigActiveCellInfo* activeCellInfo,
const std::vector<cvf::Vec3d>& vxs,
int unNamedFaultIdx,
int unNamedFaultWithInactiveIdx,
std::vector<RigFault::FaultFace>& unNamedFaultFaces,
std::vector<RigFault::FaultFace>& unNamedFaultFacesInactive,
RigFaultsPrCellAccumulator* faultsPrCellAcc ) const
{ {
if ( m_cells[gcIdx].isInvalid() ) if ( m_cells[gcIdx].isInvalid() )
{ {
continue; return;
} }
size_t neighborReservoirCellIdx; size_t neighborReservoirCellIdx;
@ -461,7 +493,7 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo )
size_t j = 0; size_t j = 0;
size_t k = 0; size_t k = 0;
RigGridBase* hostGrid = nullptr; const RigGridBase* hostGrid = nullptr;
bool firstNO_FAULTFaceForCell = true; bool firstNO_FAULTFaceForCell = true;
bool isCellActive = true; bool isCellActive = true;
@ -527,10 +559,8 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo )
int faultIdx = unNamedFaultIdx; int faultIdx = unNamedFaultIdx;
if ( !( isCellActive && isNeighborCellActive ) ) faultIdx = unNamedFaultWithInactiveIdx; if ( !( isCellActive && isNeighborCellActive ) ) faultIdx = unNamedFaultWithInactiveIdx;
m_faultsPrCellAcc->setFaultIdx( gcIdx, face, faultIdx ); faultsPrCellAcc->setFaultIdx( gcIdx, face, faultIdx );
m_faultsPrCellAcc->setFaultIdx( neighborReservoirCellIdx, faultsPrCellAcc->setFaultIdx( neighborReservoirCellIdx, StructGridInterface::oppositeFace( face ), faultIdx );
StructGridInterface::oppositeFace( face ),
faultIdx );
// Add as fault face only if the grid index is less than the neighbors // Add as fault face only if the grid index is less than the neighbors
@ -539,25 +569,25 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo )
RigFault::FaultFace ff( gcIdx, cvf::StructGridInterface::FaceType( faceIdx ), neighborReservoirCellIdx ); RigFault::FaultFace ff( gcIdx, cvf::StructGridInterface::FaceType( faceIdx ), neighborReservoirCellIdx );
if ( isCellActive && isNeighborCellActive ) if ( isCellActive && isNeighborCellActive )
{ {
unNamedFault->faultFaces().push_back( ff ); unNamedFaultFaces.push_back( ff );
} }
else else
{ {
unNamedFaultWithInactive->faultFaces().push_back( ff ); unNamedFaultFacesInactive.push_back( ff );
} }
} }
else else
{ {
CVF_FAIL_MSG( CVF_FAIL_MSG( "Found fault with global neighbor index less than the native index. " ); // Should never
"Found fault with global neighbor index less than the native index. " ); // Should never occur. // occur. because
// because we flag the // we flag the
// opposite face in the // opposite face
// in the
// faultsPrCellAcc // faultsPrCellAcc
} }
} }
} }
} }
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///

View File

@ -73,6 +73,15 @@ public:
cvf::Collection<RigFault>& faults(); cvf::Collection<RigFault>& faults();
void calculateFaults( const RigActiveCellInfo* activeCellInfo ); void calculateFaults( const RigActiveCellInfo* activeCellInfo );
void addUnNamedFaultFaces( int gcIdx,
const RigActiveCellInfo* activeCellInfo,
const std::vector<cvf::Vec3d>& vxs,
int unNamedFaultIdx,
int unNamedFaultWithInactiveIdx,
std::vector<RigFault::FaultFace>& unNamedFaultFaces,
std::vector<RigFault::FaultFace>& unNamedFaultFacesInactive,
RigFaultsPrCellAccumulator* faultsPrCellAcc ) const;
void distributeNNCsToFaults(); void distributeNNCsToFaults();
const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex,