19 #ifndef GEOS_MESH_UTILITIES_MESHMAPUTILITIES_HPP 
   20 #define GEOS_MESH_UTILITIES_MESHMAPUTILITIES_HPP 
   34 namespace meshMapUtilities
 
   45 template< 
typename T, 
int USD >
 
   57 template< 
typename T >
 
   69 template< 
typename T >
 
   87 template< 
typename POLICY, 
typename VIEW_TYPE >
 
   95   counts.setValues< POLICY >( overAlloc );
 
   96   forAll< POLICY >( 
size0( srcMap ), [srcMap, counts = counts.toView()] ( 
localIndex const srcIndex )
 
   98     for( localIndex const dstIndex : srcMap[ srcIndex ] )
 
  100       RAJA::atomicInc< AtomicPolicy< POLICY > >( &counts[ dstIndex ] );
 
  106   dstMap.resizeFromCapacities< parallelHostPolicy >( dstSize, counts.data() );
 
  109   forAll< POLICY >( 
size0( srcMap ), [srcMap, dstMap = dstMap.toView()] ( 
localIndex const srcIndex )
 
  111     for( localIndex const dstIndex : srcMap[ srcIndex ] )
 
  113       dstMap.emplaceBackAtomic< AtomicPolicy< POLICY > >( dstIndex, srcIndex );
 
  127 template< 
typename POLICY >
 
  133   localIndex const numObjects = srcMap.toCellIndex.size();
 
  135   localIndex const * offsets = srcMap.toCellIndex.toViewConst().getOffsets();
 
  136   dstMap.m_toElementRegion.resizeFromOffsets( numObjects, offsets );
 
  137   dstMap.m_toElementSubRegion.resizeFromOffsets( numObjects, offsets );
 
  138   dstMap.m_toElementIndex.resizeFromOffsets( numObjects, offsets );
 
  140   forAll< POLICY >( numObjects, [toCell = srcMap.toCellIndex.toViewConst(),
 
  141                                  toBlock = srcMap.toBlockIndex.toViewConst(),
 
  142                                  toRegion = dstMap.m_toElementRegion.toView(),
 
  143                                  toSubRegion = dstMap.m_toElementSubRegion.toView(),
 
  144                                  toElement = dstMap.m_toElementIndex.toView(),
 
  145                                  blockToSubRegion]( 
localIndex const objIndex )
 
  147     arraySlice1d< localIndex const > const cells = toCell[objIndex];
 
  148     for( localIndex i = 0; i < cells.size(); ++i )
 
  150       localIndex const blockIndex = toBlock( objIndex, i );
 
  151       localIndex const er = blockToSubRegion( blockIndex, 0 );
 
  152       localIndex const esr = blockToSubRegion( blockIndex, 1 );
 
  155       if( er >= 0 && esr >= 0 )
 
  157         toRegion.emplaceBack( objIndex, er );
 
  158         toSubRegion.emplaceBack( objIndex, esr );
 
  159         toElement.emplaceBack( objIndex, cells[i] );
 
  172 template< 
typename POLICY, 
typename PERM1, 
typename PERM2 >
 
  178   localIndex const numObjects = srcMap.toCellIndex.size( 0 );
 
  179   localIndex const maxCellsPerObject = srcMap.toCellIndex.size( 1 );
 
  181   dstMap.m_toElementRegion.resize( numObjects, maxCellsPerObject );
 
  182   dstMap.m_toElementSubRegion.resize( numObjects, maxCellsPerObject );
 
  183   dstMap.m_toElementIndex.resize( numObjects, maxCellsPerObject );
 
  185   forAll< POLICY >( numObjects, [toCell = srcMap.toCellIndex.toViewConst(),
 
  186                                  toBlock = srcMap.toBlockIndex.toViewConst(),
 
  187                                  toRegion = dstMap.m_toElementRegion.toView(),
 
  188                                  toSubRegion = dstMap.m_toElementSubRegion.toView(),
 
  189                                  toElement = dstMap.m_toElementIndex.toView(),
 
  191                                  maxCellsPerObject]( 
localIndex const objIndex )
 
  193     arraySlice1d< localIndex const > const cells = toCell[objIndex];
 
  194     localIndex cellCount = 0;
 
  195     for( localIndex i = 0; i < maxCellsPerObject && cells[i] >= 0; ++i )
 
  197       localIndex const blockIndex = toBlock( objIndex, i );
 
  198       localIndex const er = blockToSubRegion( blockIndex, 0 );
 
  199       localIndex const esr = blockToSubRegion( blockIndex, 1 );
 
  202       if( er >= 0 && esr >= 0 )
 
  204         toRegion( objIndex, cellCount ) = er;
 
  205         toSubRegion( objIndex, cellCount ) = esr;
 
  206         toElement( objIndex, cellCount ) = cells[i];
 
  219 template< 
typename T >
 
  232       hash ^= std::hash< T >{} ( v )  + 0x9e3779b9 + ( hash << 6 ) + ( hash >> 2 );
 
  243 template< 
typename T >
 
  246   return std::array< T, 6 > { v, -1, -1, -1, -1, -1 };
 
  257 template< 
typename T >
 
  266     return std::array< T, 6 > { v1, v2, -1, -1, a, -1 };
 
  270     return std::array< T, 6 > { v2, v1, -1, -1, order - a, -1 };
 
  285 template< 
typename T >
 
  286 static std::array< T, 6 > 
createNodeKey( T v1, T v2, T v3, T v4, 
int a, 
int b, 
int order )
 
  298   while( v1 > v2 || v1 > v3 || v1 > v4 || v2 > v3 )
 
  325   return std::array< T, 6 > { v1, v2, v3, v4, a, b };
 
  337 template< 
typename T >
 
  338 static std::array< T, 6 > 
createNodeKey( T 
const (&elemNodes)[ 8 ], 
int q1, 
int q2, 
int q3, 
int order )
 
  340   bool extremal1 = q1 == 0 || q1 == order;
 
  341   bool extremal2 = q2 == 0 || q2 == order;
 
  342   bool extremal3 = q3 == 0 || q3 == order;
 
  346   if( extremal1 && extremal2 && extremal3 )
 
  351   else if( extremal1 && extremal2 )
 
  354     return createNodeKey( elemNodes[ v1 + 2*v2 ], elemNodes[ v1 + 2*v2 + 4 ], q3, order );
 
  356   else if( extremal1 && extremal3 )
 
  359     return createNodeKey( elemNodes[ v1 + 4*v3 ], elemNodes[ v1 + 2 + 4*v3 ], q2, order );
 
  361   else if( extremal2 && extremal3 )
 
  364     return createNodeKey( elemNodes[ 2*v2 + 4*v3 ], elemNodes[ 1 + 2*v2 + 4*v3 ], q1, order );
 
  369     return createNodeKey( elemNodes[ v1 ], elemNodes[ v1 + 2 ], elemNodes[ v1 + 4 ], elemNodes[ v1 + 2 + 4 ], q2, q3, order );
 
  374     return createNodeKey( elemNodes[ 2*v2 ], elemNodes[ 1 + 2*v2 ], elemNodes[ 2*v2 + 4 ], elemNodes[ 1 + 2*v2 + 4 ], q1, q3, order );
 
  379     return createNodeKey( elemNodes[ 4*v3 ], elemNodes[ 1 + 4*v3 ], elemNodes[ 2 + 4*v3 ], elemNodes[ 1 + 2 + 4*v3 ], q1, q2, order );
 
#define GEOS_HOST_DEVICE
Marks a host-device function.
 
#define GEOS_ASSERT_EQ(lhs, rhs)
Assert that two values compare equal in debug builds.
 
A relationship to an element.
 
Base template for ordered and unordered maps.
 
ArrayOfArrays< std::remove_const_t< typename VIEW_TYPE::ValueType > > transposeIndexMap(VIEW_TYPE const &srcMap, localIndex const dstSize, localIndex const overAlloc=0)
Transposes an input map (array2d, ArrayOfArrays or ArrayOfSets)
 
void transformCellBlockToRegionMap(arrayView2d< localIndex const > const &blockToSubRegion, ToCellRelation< array2d< localIndex, PERM1 > > const &srcMap, ToElementRelation< array2d< localIndex, PERM2 > > &dstMap)
Convert ToCellRelation into ToElementRelation.
 
GEOS_HOST_DEVICE localIndex size0(arrayView2d< T, USD > const &map)
 
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
 
LvArray::ArrayOfSetsView< T, INDEX_TYPE const, LvArray::ChaiBuffer > ArrayOfSetsView
View of array of variable-sized sets. See LvArray::ArrayOfSetsView for details.
 
LvArray::ArrayOfArraysView< T, INDEX_TYPE const, CONST_SIZES, LvArray::ChaiBuffer > ArrayOfArraysView
View of array of variable-sized arrays. See LvArray::ArrayOfArraysView for details.
 
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
 
std::size_t size_t
Unsigned size type.
 
static std::array< T, 6 > createNodeKey(T const (&elemNodes)[8], int q1, int q2, int q3, int order)
 
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
 
Array< T, 1 > array1d
Alias for 1D array.
 
LvArray::ArrayOfArrays< T, INDEX_TYPE, LvArray::ChaiBuffer > ArrayOfArrays
Array of variable-sized arrays. See LvArray::ArrayOfArrays for details.
 
Strucure used to hash interpolation arrays representing high-order nodes.
 
std::size_t operator()(const std::array< T, 6 > &arr) const
 
Container for maps from a mesh object (node, edge or face) to cells.