packages/MC/geometry/Cartesian_Mesh.cc
//---------------------------------------------------------------------------//
/*!
 * \brief Initialize cartesian mesh with cell edges.
 *
 * To make this a 2-D mesh, leave the z edges empty.
 */
\brief Initialize cartesian mesh with cell edges.
To make this a 2-D mesh, leave the z edges empty.
\ brief Initialize cartesian mesh with cell edges . To make this a 2 - D mesh leave the z edges empty .
Cartesian_Mesh::Cartesian_Mesh(const Vec_Dbl& x_edges,
                               const Vec_Dbl& y_edges,
                               const Vec_Dbl& z_edges)
    : d_edges(x_edges, y_edges, z_edges)
{
    d_num_cells = 1;
    d_dimension = 0;
    for (int ax = 0; ax < 3; ++ax)
    {
        if (d_edges[ax].empty())
        {
            d_extents[ax] = 1;
            break;
        }
        d_extents[ax] = d_edges[ax].size() - 1;
        d_num_cells *= d_extents[ax];
        ++d_dimension;
        VALIDATE(profugus::is_sorted(d_edges[ax].begin(), d_edges[ax].end()),
                 "Mesh along " << "xyz"[ax] << " axis is not monotonically "
                 "increasing.");
    }
    VALIDATE(d_dimension == 3 || (d_dimension == 2 && d_edges[def::Z].empty()),
             "Only xy and xyz meshes are currently supported.");
    ENSURE(d_dimension >= 2);
    ENSURE(d_num_cells >= 1);
}
Cartesian_Mesh :: Cartesian_Mesh ( const Vec_Dbl & x_edges , const Vec_Dbl & y_edges , const Vec_Dbl & z_edges ) : d_edges ( x_edges , y_edges , z_edges ) { d_num_cells = 1 ; d_dimension = 0 ; for ( int ax = 0 ; ax < 3 ; ++ ax ) { if ( d_edges [ ax ] . empty ( ) ) { d_extents [ ax ] = 1 ; break ; } d_extents [ ax ] = d_edges [ ax ] . size ( ) - 1 ; d_num_cells *= d_extents [ ax ] ; ++ d_dimension ; VALIDATE ( profugus :: is_sorted ( d_edges [ ax ] . begin ( ) , d_edges [ ax ] . end ( ) ) , " " << " " [ ax ] << " " " " ) ; } VALIDATE ( d_dimension == 3 || ( d_dimension == 2 && d_edges [ def :: Z ] . empty ( ) ) , " " ) ; ENSURE ( d_dimension >= 2 ) ; ENSURE ( d_num_cells >= 1 ) ; }
\brief Initialize cartesian mesh with cell edges.
\ brief Initialize cartesian mesh with cell edges .
// Set extents along this axis // Set number of cells // Increase dimension // For now only support 2-D (missing Z) or 3-D