packages/SPn/mesh/Mesh.cc
//---------------------------------------------------------------------------//
// PRIVATE FUNCTIONS
//---------------------------------------------------------------------------//
/*!
 * \brief Builds number of cells, cell widths, inverse widths
 */
PRIVATE FUNCTIONS
\brief Builds number of cells, cell widths, inverse widths
PRIVATE FUNCTIONS \ brief Builds number of cells cell widths inverse widths
void Mesh::build_mesh()
{
    using def::K;
    REQUIRE(d_dimension == 2 || d_dimension == 3);
    REQUIRE(d_dimension == 2 || d_blocks[K] > 0);
#ifdef REQUIRE_ON
    for (unsigned int d = 0; d < d_dimension; ++d)
        REQUIRE(!d_edges[d].empty());
#endif
    if (d_dimension == 2)
    {
        d_edges[K].resize(2);
        d_edges[K][0] = -0.5;
        d_edges[K][1] =  0.5;
        d_blocks[K] = 1;
    }
    for (unsigned int d = 0; d < 3; ++d)
    {
        d_N[d]  = d_edges[d].size() - 1;
        d_Nb[d] = d_N[d];
    }
    d_Nb[K] /= d_blocks[K];
    d_num_cells    = 1;
    d_num_vertices = 1;
    for (unsigned int d = 0; d < 3; ++d)
    {
        d_num_cells    *= d_N[d];
        d_num_vertices *= d_edges[d].size();
    }
    if (d_dimension == 2)
        d_num_vertices /= 2;
    for (unsigned int d = 0; d < 3; ++d)
    {
        d_width[d].resize(d_N[d]);
        d_inv_width[d].resize(d_N[d]);
        for (int l = 0; l < d_N[d]; ++l)
        {
            d_width[d][l] = d_edges[d][l+1] - d_edges[d][l];
            CHECK(d_width[d][l] > 0.0);
            d_inv_width[d][l] = 1.0 / d_width[d][l];
        }
    }
}
void Mesh :: build_mesh ( ) { using def :: K ; REQUIRE ( d_dimension == 2 || d_dimension == 3 ) ; REQUIRE ( d_dimension == 2 || d_blocks [ K ] > 0 ) ; #ifdef REQUIRE_ON for ( unsigned int d = 0 ; d < d_dimension ; ++ d ) REQUIRE ( ! d_edges [ d ] . empty ( ) ) ; #endif if ( d_dimension == 2 ) { d_edges [ K ] . resize ( 2 ) ; d_edges [ K ] [ 0 ] = -0.5 ; d_edges [ K ] [ 1 ] = 0.5 ; d_blocks [ K ] = 1 ; } for ( unsigned int d = 0 ; d < 3 ; ++ d ) { d_N [ d ] = d_edges [ d ] . size ( ) - 1 ; d_Nb [ d ] = d_N [ d ] ; } d_Nb [ K ] /= d_blocks [ K ] ; d_num_cells = 1 ; d_num_vertices = 1 ; for ( unsigned int d = 0 ; d < 3 ; ++ d ) { d_num_cells *= d_N [ d ] ; d_num_vertices *= d_edges [ d ] . size ( ) ; } if ( d_dimension == 2 ) d_num_vertices /= 2 ; for ( unsigned int d = 0 ; d < 3 ; ++ d ) { d_width [ d ] . resize ( d_N [ d ] ) ; d_inv_width [ d ] . resize ( d_N [ d ] ) ; for ( int l = 0 ; l < d_N [ d ] ; ++ l ) { d_width [ d ] [ l ] = d_edges [ d ] [ l + 1 ] - d_edges [ d ] [ l ] ; CHECK ( d_width [ d ] [ l ] > 0.0 ) ; d_inv_width [ d ] [ l ] = 1.0 / d_width [ d ] [ l ] ; } } }
PRIVATE FUNCTIONS
 \brief Builds number of cells, cell widths, inverse widths
PRIVATE FUNCTIONS \ brief Builds number of cells cell widths inverse widths
// Set Z axis to a unit length centered about zero // Set number of K blocks to one // >>> Calculate number of cell in each dimension // Z block count is divided by number of k blocks (1 if 2D) // >>> Calculate number of cells // In the 2D case, our two "edges" along the K axis really only count as // one vertex in the plane // >>> Build cell widths and inverse widths // cell width // inverse width