packages/SPn/mesh/Partitioner.cc
//---------------------------------------------------------------------------//
/*!
 * \brief Communicate the number of cells in each block along I/J
 */
\brief Communicate the number of cells in each block along I/J
\ brief Communicate the number of cells in each block along I / J
void Partitioner::set_global_num(const Dim_Vector& local_num_cells,
                                 IJ_Vec_Int&       global_num) const
{
    using def::I; using def::J; using def::K;
    REQUIRE(local_num_cells[I] > 0);
    REQUIRE(local_num_cells[J] > 0);
    IJ_Vec_Int global_cells;
    global_cells[I].assign(d_num_blocks, 0);
    global_cells[J].assign(d_num_blocks, 0);
    for (int dir = 0; dir < K; ++dir)
    {
        global_cells[dir][d_block] = local_num_cells[dir];
        profugus::global_max(&(global_cells[dir][0]), d_num_blocks);
    }
    global_num[I].assign(global_cells[I].begin(),
                         global_cells[I].begin() + d_Nb[I]);
    global_num[J].resize(d_Nb[J]);
    for (int j = 0, n = 0; j < d_Nb[J]; ++j)
    {
        n = j * d_Nb[I];
        CHECK(n >= 0 && n < d_nodes);
        global_num[J][j] = global_cells[J][n];
    }
    ENSURE(global_num[I].size() == d_Nb[I]);
    ENSURE(global_num[J].size() == d_Nb[J]);
    ENSURE(global_num[I].front() > 0);
    ENSURE(global_num[J].front() > 0);
}
void Partitioner :: set_global_num ( const Dim_Vector & local_num_cells , IJ_Vec_Int & global_num ) const { using def :: I ; using def :: J ; using def :: K ; REQUIRE ( local_num_cells [ I ] > 0 ) ; REQUIRE ( local_num_cells [ J ] > 0 ) ; IJ_Vec_Int global_cells ; global_cells [ I ] . assign ( d_num_blocks , 0 ) ; global_cells [ J ] . assign ( d_num_blocks , 0 ) ; for ( int dir = 0 ; dir < K ; ++ dir ) { global_cells [ dir ] [ d_block ] = local_num_cells [ dir ] ; profugus :: global_max ( & ( global_cells [ dir ] [ 0 ] ) , d_num_blocks ) ; } global_num [ I ] . assign ( global_cells [ I ] . begin ( ) , global_cells [ I ] . begin ( ) + d_Nb [ I ] ) ; global_num [ J ] . resize ( d_Nb [ J ] ) ; for ( int j = 0 , n = 0 ; j < d_Nb [ J ] ; ++ j ) { n = j * d_Nb [ I ] ; CHECK ( n >= 0 && n < d_nodes ) ; global_num [ J ] [ j ] = global_cells [ J ] [ n ] ; } ENSURE ( global_num [ I ] . size ( ) == d_Nb [ I ] ) ; ENSURE ( global_num [ J ] . size ( ) == d_Nb [ J ] ) ; ENSURE ( global_num [ I ] . front ( ) > 0 ) ; ENSURE ( global_num [ J ] . front ( ) > 0 ) ; }
\brief Communicate the number of cells in each block along I/J
\ brief Communicate the number of cells in each block along I / J
// global number of cells on each domain // assign this processors cells in I/J to the global list // fill up the global cell list for this direction // loop through the first row of I (J = 0) and calculate the numbers from // the global cell processor list as we did above to calculate the spatial // offset for the block // loop through first column of J (I = 0) and calculate the numbers from // the global cell processor list as we did above to calculate the spatial // offset for the block // calculate index into global cell processor list