Skip to content

Commit

Permalink
Refactor toElement map construction + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
klevzoff committed Apr 2, 2022
1 parent f9c295b commit ac9ae59
Show file tree
Hide file tree
Showing 34 changed files with 515 additions and 495 deletions.
7 changes: 2 additions & 5 deletions src/coreComponents/mainInterface/ProblemManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,9 @@ void ProblemManager::generateMesh()

elemManager.generateMesh( cellBlockManager );

nodeManager.setGeometricalRelations( cellBlockManager );
nodeManager.setGeometricalRelations( cellBlockManager, elemManager );
edgeManager.setGeometricalRelations( cellBlockManager );
faceManager.setGeometricalRelations( cellBlockManager, nodeManager );

nodeManager.buildRegionMaps( elemManager );
faceManager.buildRegionMaps( elemManager );
faceManager.setGeometricalRelations( cellBlockManager, elemManager, nodeManager );

nodeManager.constructGlobalToLocalMap( cellBlockManager );

Expand Down
6 changes: 3 additions & 3 deletions src/coreComponents/mesh/CellElementRegion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ class CellElementRegion : public ElementRegionBase
* @brief The key name for the FaceElementRegion in the object catalog.
* @return A string containing the key name.
*/
static const string catalogName()
static string catalogName()
{ return "CellElementRegion"; }

/**
* @copydoc catalogName()
*/
virtual const string getCatalogName() const override final
{ return CellElementRegion::catalogName(); }
virtual string getCatalogName() const override final
{ return catalogName(); }

///@}

Expand Down
4 changes: 3 additions & 1 deletion src/coreComponents/mesh/CellElementSubRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ void CellElementSubRegion::
void CellElementSubRegion::calculateElementGeometricQuantities( NodeManager const & nodeManager,
FaceManager const & GEOSX_UNUSED_PARAM( faceManager ) )
{
arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const & X = nodeManager.referencePosition();
GEOSX_MARK_FUNCTION;

arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const X = nodeManager.referencePosition();

forAll< parallelHostPolicy >( this->size(), [=] ( localIndex const k )
{
Expand Down
6 changes: 3 additions & 3 deletions src/coreComponents/mesh/CellElementSubRegion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ class CellElementSubRegion : public ElementSubRegionBase
* @brief Const getter for the catalog name.
* @return the name of this type in the catalog
*/
static const string catalogName()
static string catalogName()
{ return "CellElementSubRegion"; }

/**
* @copydoc catalogName()
*/
virtual const string getCatalogName() const override final
{ return CellElementSubRegion::catalogName(); }
virtual string getCatalogName() const override final
{ return catalogName(); }

/**
* @name Constructor / Destructor
Expand Down
34 changes: 17 additions & 17 deletions src/coreComponents/mesh/EdgeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,27 @@ void EdgeManager::buildEdges( localIndex const numNodes,
ArrayOfArraysView< localIndex const > const & faceToNodeMap,
ArrayOfArrays< localIndex > & faceToEdgeMap )
{
ArrayOfArrays< localIndex > edgeToFace;
localIndex const numEdges = buildEdgeMaps( numNodes,
faceToNodeMap,
faceToEdgeMap,
m_toFacesRelation,
edgeToFace,
m_toNodesRelation );

m_toFacesRelation.base().assimilate< parallelHostPolicy >( std::move( edgeToFace ),
LvArray::sortedArrayManipulation::UNSORTED_NO_DUPLICATES );
resize( numEdges );
}

void EdgeManager::setGeometricalRelations( CellBlockManagerABC const & cellBlockManager )
{
GEOSX_MARK_FUNCTION;

resize( cellBlockManager.numEdges() );

m_toNodesRelation.base() = cellBlockManager.getEdgeToNodes();
m_toFacesRelation.base() = cellBlockManager.getEdgeToFaces();
m_toFacesRelation.base().assimilate< parallelHostPolicy >( cellBlockManager.getEdgeToFaces(),
LvArray::sortedArrayManipulation::UNSORTED_NO_DUPLICATES );
}

void EdgeManager::setupRelatedObjectsInRelations( NodeManager const & nodeManager,
Expand All @@ -120,31 +126,25 @@ void EdgeManager::setupRelatedObjectsInRelations( NodeManager const & nodeManage

void EdgeManager::setDomainBoundaryObjects( FaceManager const & faceManager )
{
// get the "isDomainBoundary" field from the faceManager. This should have
// been set already!
arrayView1d< integer const > const & isFaceOnDomainBoundary = faceManager.getDomainBoundaryIndicator();
// get the "isDomainBoundary" field from the faceManager. This should have been set already!
arrayView1d< integer const > const isFaceOnDomainBoundary = faceManager.getDomainBoundaryIndicator();

// get the "isDomainBoundary" field from for *this, and set it to zero
arrayView1d< integer > const & isEdgeOnDomainBoundary = this->getDomainBoundaryIndicator();
arrayView1d< integer > const isEdgeOnDomainBoundary = this->getDomainBoundaryIndicator();
isEdgeOnDomainBoundary.zero();

ArrayOfArraysView< localIndex const > const & faceToEdgeMap = faceManager.edgeList().toViewConst();
ArrayOfArraysView< localIndex const > const faceToEdgeMap = faceManager.edgeList().toViewConst();

// loop through all faces
for( localIndex kf = 0; kf < faceManager.size(); ++kf )
forAll< parallelHostPolicy >( faceManager.size(), [=]( localIndex const faceIndex )
{
// check to see if the face is on a domain boundary
if( isFaceOnDomainBoundary[kf] == 1 )
if( isFaceOnDomainBoundary[faceIndex] == 1 )
{
localIndex const numFaceEdges = faceToEdgeMap.sizeOfArray( kf );

// loop over all nodes connected to face, and set isNodeDomainBoundary
for( localIndex a = 0; a < numFaceEdges; ++a )
for( localIndex const edgeIndex : faceToEdgeMap[faceIndex] )
{
isEdgeOnDomainBoundary( faceToEdgeMap( kf, a ) ) = 1;
isEdgeOnDomainBoundary[edgeIndex] = 1;
}
}
}
} );
}

bool EdgeManager::hasNode( const localIndex edgeIndex, const localIndex nodeIndex ) const
Expand Down
10 changes: 5 additions & 5 deletions src/coreComponents/mesh/EdgeManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ class EdgeManager : public ObjectManagerBase
/**
* @return the string representing the edge manager name in the catalog
*/
static const string catalogName()
static string catalogName()
{ return "EdgeManager"; }


/**
* @brief Getter used to access the edge manager catalog name.
* @return the edge manager catalog name
*/
virtual const string getCatalogName() const override
{ return EdgeManager::catalogName(); }
virtual string getCatalogName() const override
{ return catalogName(); }

///@}

Expand Down Expand Up @@ -103,9 +103,9 @@ class EdgeManager : public ObjectManagerBase

/**
* @brief Set the node of the domain boundary object.
* @param[in] faceManager The reference of the face manager.
* @param[in] faceIndex The reference of the face manager.
*/
void setDomainBoundaryObjects( FaceManager const & faceManager );
void setDomainBoundaryObjects( FaceManager const & faceIndex );

/**
* @brief Set external edges.
Expand Down
33 changes: 28 additions & 5 deletions src/coreComponents/mesh/ElementRegionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ void ElementRegionManager::setMaxGlobalIndex()
m_localMaxGlobalIndex = std::max( m_localMaxGlobalIndex, subRegion.maxGlobalIndex() );
} );

MpiWrapper::allReduce( &m_localMaxGlobalIndex,
&m_maxGlobalIndex,
1,
MPI_MAX,
MPI_COMM_GEOSX );
m_maxGlobalIndex = MpiWrapper::max( m_localMaxGlobalIndex, MPI_COMM_GEOSX );
}


Expand Down Expand Up @@ -630,6 +626,33 @@ ElementRegionManager::unpackFracturedElements( buffer_unit_type const * & buffer
return unpackedSize;
}

array2d< localIndex >
ElementRegionManager::getCellBlockToSubRegionMap( CellBlockManagerABC const & cellBlockManager ) const
{
array2d< localIndex > blockMap( cellBlockManager.getCellBlocks().numSubGroups(), 2 );
blockMap.setValues< serialPolicy >( -1 );

Group::subGroupMap const & cellBlocks = cellBlockManager.getCellBlocks().getSubGroups();

forElementSubRegionsComplete< CellElementSubRegion >( [blockMap = blockMap.toView(),
&cellBlocks]( localIndex const er,
localIndex const esr,
ElementRegionBase const & region,
CellElementSubRegion const & subRegion )
{
localIndex const blockIndex = cellBlocks.getIndex( subRegion.getName() );
GEOSX_ERROR_IF( blockIndex == Group::subGroupMap::KeyIndex::invalid_index,
GEOSX_FMT( "Cell block not found for subregion {}/{}", region.getName(), subRegion.getName() ) );
GEOSX_ERROR_IF( blockMap( blockIndex, 1 ) != -1,
GEOSX_FMT( "Cell block {} mapped to more than one subregion", subRegion.getName() ) );

blockMap( blockIndex, 0 ) = er;
blockMap( blockIndex, 1 ) = esr;
} );

return blockMap;
}


REGISTER_CATALOG_ENTRY( ObjectManagerBase, ElementRegionManager, string const &, Group * const )
}
14 changes: 11 additions & 3 deletions src/coreComponents/mesh/ElementRegionManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ class ElementRegionManager : public ObjectManagerBase
* @brief The function is to return the name of the ElementRegionManager in the object catalog
* @return string that contains the catalog name used to register/lookup this class in the object catalog
*/
static const string catalogName()
static string catalogName()
{ return "ZoneManager"; }

/**
* @brief Virtual access to catalogName()
* @return string that contains the catalog name used to register/lookup this class in the object catalog
*/
virtual const string getCatalogName() const override final
{ return ElementRegionManager::catalogName(); }
virtual string getCatalogName() const override final
{ return catalogName(); }

/**
* @brief Constructor.
Expand Down Expand Up @@ -264,6 +264,14 @@ class ElementRegionManager : public ObjectManagerBase
return this->getRegions().size();
}

/**
* @brief Produce a map from cell block indices to element region and subregion indices
* @param cellBlockManager the CellBlocKManager
* @return a (numBlock x 2) array with each row corresponding to a cell block and containing
* region (first entry) and subregion (second entry) indices, or -1 if block was not used.
*/
array2d< localIndex > getCellBlockToSubRegionMap( CellBlockManagerABC const & cellBlockManager ) const;

/**
* @brief This function is used to launch kernel function over all the element regions with region type =
* ElementRegionBase.
Expand Down
4 changes: 2 additions & 2 deletions src/coreComponents/mesh/EmbeddedSurfaceNodeManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ class EmbeddedSurfaceNodeManager : public ObjectManagerBase
* @brief Provide a virtual access to catalogName().
* @return string that contains the EmbeddedSurfaceNodeManager catalog name
*/
const string getCatalogName() const override final
{ return EmbeddedSurfaceNodeManager::catalogName(); }
string getCatalogName() const override final
{ return catalogName(); }

///@}

Expand Down
6 changes: 3 additions & 3 deletions src/coreComponents/mesh/EmbeddedSurfaceSubRegion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ class EmbeddedSurfaceSubRegion : public SurfaceElementSubRegion
* @brief Get catalog name.
* @return the catalog name
*/
static const string catalogName()
static string catalogName()
{ return "EmbeddedSurfaceSubRegion"; }

/**
* @brief Get catalog name.
* @return the catalog name
*/
virtual const string getCatalogName() const override
virtual string getCatalogName() const override
{
return EmbeddedSurfaceSubRegion::catalogName();
return catalogName();
}

///@}
Expand Down
6 changes: 3 additions & 3 deletions src/coreComponents/mesh/FaceElementSubRegion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ class FaceElementSubRegion : public SurfaceElementSubRegion
* @brief Get catalog name.
* @return the catalog name
*/
static const string catalogName()
static string catalogName()
{ return "FaceElementSubRegion"; }

/**
* @brief Get catalog name.
* @return the catalog name
*/
virtual const string getCatalogName() const override
virtual string getCatalogName() const override
{
return FaceElementSubRegion::catalogName();
return catalogName();
}

///@}
Expand Down
Loading

0 comments on commit ac9ae59

Please sign in to comment.