Skip to content

Commit

Permalink
fix parallel crash and clarify output
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Tomin authored and Pavel Tomin committed Jan 13, 2025
1 parent 7a15d18 commit 090f555
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/coreComponents/mesh/WellElementSubRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,19 @@ bool searchLocalElements( MeshLevel const & mesh,
ElementSubRegionBase const & subRegionBase = region.getSubRegion( esr );
region.applyLambdaToContainer< CellElementSubRegion, SurfaceElementSubRegion >( subRegionBase, [&]( auto const & subRegion )
{
GEOS_LOG( GEOS_FMT( " searching well connections with region/subregion: {}/{}", region.getName(), subRegion.getName() ) );
GEOS_LOG_RANK_0( GEOS_FMT( " searching well connections with region/subregion: {}/{}", region.getName(), subRegion.getName() ) );

// first, we search for the reservoir element that is the *closest* from the center of well element
// note that this reservoir element does not necessarily contain the center of the well element
// this "init" reservoir element will be used later to find the reservoir element that
// contains the well element
localIndex eiInit = -1;
localIndex eiInit = -1;

initializeLocalSearch( mesh, location, targetRegionIndex, esr, eiInit );

if( eiInit < 0 ) // nothing found, skip the rest
return;

// loop over the reservoir elements that are in the neighborhood of (esrInit,eiInit)
// search locally, starting from the location of the previous perforation
// the assumption here is that perforations have been entered in order of depth
Expand Down Expand Up @@ -374,8 +378,11 @@ bool searchLocalElements( MeshLevel const & mesh,

if( resElemFound || nNodes == nodes.size())
{
esrMatched = esr;
GEOS_LOG( GEOS_FMT( " found {}/{}/{}", region.getName(), subRegion.getName(), eiMatched ) );
if( resElemFound )
{
esrMatched = esr;
GEOS_LOG( GEOS_FMT( " found {}/{}/{}", region.getName(), subRegion.getName(), giMatched ) );
}
// TODO learn how to exit forElementSubRegionsIndex
break;
}
Expand Down Expand Up @@ -505,23 +512,24 @@ void WellElementSubRegion::assignUnownedElementsInReservoir( MeshLevel & mesh,
// assign the well elements based on location wrt the reservoir elements
// if the center of the well element falls in the domain owned by rank k
// then the well element is assigned to rank k
bool resElemFound = false;
for( globalIndex currGlobal : unownedElems )
{
real64 const location[3] = { wellElemCoordsGlobal[currGlobal][0],
wellElemCoordsGlobal[currGlobal][1],
wellElemCoordsGlobal[currGlobal][2] };

// for each perforation, we have to find the reservoir element that contains the perforation
bool resElemFound = false;
for( localIndex er = 0; er < elemManager.numRegions(); er++ )
{
// search for the reservoir element that contains the well element
localIndex esrMatched = -1;
localIndex eiMatched = -1;
globalIndex giMatched = -1;
if( searchLocalElements( mesh, location, m_searchDepth, er, esrMatched, eiMatched, giMatched ))
globalIndex giMatched = -1;
resElemFound = searchLocalElements( mesh, location, m_searchDepth, er, esrMatched, eiMatched, giMatched );

if( resElemFound )
{
resElemFound = true;
break;
}
}
Expand Down Expand Up @@ -821,8 +829,9 @@ void WellElementSubRegion::connectPerforationsToMeshElements( MeshLevel & mesh,
real64 const location[3] = { perfCoordsGlobal[iperfGlobal][0],
perfCoordsGlobal[iperfGlobal][1],
perfCoordsGlobal[iperfGlobal][2] };
GEOS_LOG( GEOS_FMT( "{}: perforation {} location = ({}, {}, {})", lineBlock.getName(), iperfGlobal,
location[0], location[1], location[2] ) );
GEOS_LOG_RANK_0( GEOS_FMT( "{}: perforation {} location = ({}, {}, {})",
lineBlock.getName(), iperfGlobal,
location[0], location[1], location[2] ) );

localIndex erStart = -1, erEnd = -1;

Expand Down

0 comments on commit 090f555

Please sign in to comment.