packages/SPn/mesh/Partitioner.cc
//---------------------------------------------------------------------------//
/*!
 * \brief Set spatial partitioning data
 *
 * The default partitioning scheme
 */
\brief Set spatial partitioning data
The default partitioning scheme
\ brief Set spatial partitioning data The default partitioning scheme
void Partitioner::set_spatial_partition(const Dim_Vector& index,
                                        IJK_Vec_Dbl&      local_edges,
                                        IJ_Vec_Int&       global_num) const
{
    using def::I; using def::J; using def::K;
    REQUIRE(index[I] < d_Nb[I]);
    REQUIRE(index[J] < d_Nb[J]);
    Dim_Vector global_num_cells;
    global_num_cells[I] = d_edges[I].size() - 1;
    global_num_cells[J] = d_edges[J].size() - 1;
    global_num_cells[K] = (d_dimension == 3 ? d_edges[K].size() - 1 : 1);
    Dim_Vector local_num_cells;
    for (int dir = 0; dir < K; ++dir)
    {
        CHECK(d_Nb[dir] > 0);
        local_num_cells[dir] = global_num_cells[dir] / d_Nb[dir];
        CHECK(local_num_cells[dir] > 0);
        size_type append_cells = global_num_cells[dir] % d_Nb[dir];
        CHECK(append_cells < d_Nb[dir]);
        if (index[dir] < append_cells)
            local_num_cells[dir]++;
    }
    local_num_cells[K] = global_num_cells[K];
    set_global_num(local_num_cells, global_num);
    set_local_edges(index[I], global_num[I], d_edges[I], local_edges[I]);
    set_local_edges(index[J], global_num[J], d_edges[J], local_edges[J]);
    local_edges[K].assign(d_edges[K].begin(), d_edges[K].end());
    ENSURE(local_edges[I].size() == local_num_cells[I] + 1);
    ENSURE(local_edges[J].size() == local_num_cells[J] + 1);
    ENSURE(local_edges[K].size() == local_num_cells[K] + 1 ||
            dimension() == 2);
}
void Partitioner :: set_spatial_partition ( const Dim_Vector & index , IJK_Vec_Dbl & local_edges , IJ_Vec_Int & global_num ) const { using def :: I ; using def :: J ; using def :: K ; REQUIRE ( index [ I ] < d_Nb [ I ] ) ; REQUIRE ( index [ J ] < d_Nb [ J ] ) ; Dim_Vector global_num_cells ; global_num_cells [ I ] = d_edges [ I ] . size ( ) - 1 ; global_num_cells [ J ] = d_edges [ J ] . size ( ) - 1 ; global_num_cells [ K ] = ( d_dimension == 3 ? d_edges [ K ] . size ( ) - 1 : 1 ) ; Dim_Vector local_num_cells ; for ( int dir = 0 ; dir < K ; ++ dir ) { CHECK ( d_Nb [ dir ] > 0 ) ; local_num_cells [ dir ] = global_num_cells [ dir ] / d_Nb [ dir ] ; CHECK ( local_num_cells [ dir ] > 0 ) ; size_type append_cells = global_num_cells [ dir ] % d_Nb [ dir ] ; CHECK ( append_cells < d_Nb [ dir ] ) ; if ( index [ dir ] < append_cells ) local_num_cells [ dir ] ++ ; } local_num_cells [ K ] = global_num_cells [ K ] ; set_global_num ( local_num_cells , global_num ) ; set_local_edges ( index [ I ] , global_num [ I ] , d_edges [ I ] , local_edges [ I ] ) ; set_local_edges ( index [ J ] , global_num [ J ] , d_edges [ J ] , local_edges [ J ] ) ; local_edges [ K ] . assign ( d_edges [ K ] . begin ( ) , d_edges [ K ] . end ( ) ) ; ENSURE ( local_edges [ I ] . size ( ) == local_num_cells [ I ] + 1 ) ; ENSURE ( local_edges [ J ] . size ( ) == local_num_cells [ J ] + 1 ) ; ENSURE ( local_edges [ K ] . size ( ) == local_num_cells [ K ] + 1 || dimension ( ) == 2 ) ; }
\brief Set spatial partitioning data
 The default partitioning scheme
\ brief Set spatial partitioning data The default partitioning scheme
// global number of cells in each direction // the number of cells on the I/J directions on this processor // loop through I/J directions and determine base cells per proc // estimate the base cells per pe in this direction // get the number of cells that need to be appended in this direction // if Ip/Jp is less than the number of append cells then add 1 cell // (row/column) to this block // size the z coordinates // Set global number of cells per block // Set local edge coordinates // K edges are global, so just copy them