packages/MC/geometry/Mesh_Geometry.cc
//---------------------------------------------------------------------------//
/*!
 * \brief Create cell volumes and return them.
 *
 * On first pass, the volumes are generated; thereafter they are returned.
 */
\brief Create cell volumes and return them.
On first pass, the volumes are generated; thereafter they are returned.
\ brief Create cell volumes and return them . On first pass the volumes are generated ; thereafter they are returned .
Mesh_Geometry::SP_Vec_Dbl Mesh_Geometry::get_cell_volumes()
{
    using def::I; using def::J; using def::K;
    if (!d_volumes)
    {
        d_volumes     = std::make_shared<Vec_Dbl>(num_cells(), 0.0);
        auto &volumes = *d_volumes;
        const auto &N = d_mesh.extents();
        for (int k = 0; k < N[K]; ++k)
        {
            for (int j = 0; j < N[J]; ++j)
            {
                for (int i = 0; i < N[I]; ++i)
                {
                    volumes[d_mesh.index(i,j,k)] = d_mesh.volume(i,j,k);
                }
            }
        }
    }
    ENSURE(d_volumes->size() == num_cells());
    return d_volumes;
}
Mesh_Geometry :: SP_Vec_Dbl Mesh_Geometry :: get_cell_volumes ( ) { using def :: I ; using def :: J ; using def :: K ; if ( ! d_volumes ) { d_volumes = std :: make_shared < Vec_Dbl > ( num_cells ( ) , 0.0 ) ; auto & volumes = * d_volumes ; const auto & N = d_mesh . extents ( ) ; for ( int k = 0 ; k < N [ K ] ; ++ k ) { for ( int j = 0 ; j < N [ J ] ; ++ j ) { for ( int i = 0 ; i < N [ I ] ; ++ i ) { volumes [ d_mesh . index ( i , j , k ) ] = d_mesh . volume ( i , j , k ) ; } } } } ENSURE ( d_volumes -> size ( ) == num_cells ( ) ) ; return d_volumes ; }
\brief Create cell volumes and return them.
\ brief Create cell volumes and return them .
// if the volumes do not exist make them now (lazy evaluation)