packages/Utils/utils/test/tstParallel_HDF5_Writer.cc
//---------------------------------------------------------------------------//
/*
 * This test assumes one unknown per mesh cell.  For example, integrated
 * scalar flux.  The field is ordered COLUMN-MAJOR, ie.
 *    n = i + Nx * (j + Ny * (k))
 */
This test assumes one unknown per mesh cell.  For example, integrated
scalar flux.  The field is ordered COLUMN-MAJOR, ie.
This test assumes one unknown per mesh cell . For example integrated scalar flux . The field is ordered COLUMN - MAJOR ie .
TEST_F(Parallel_Field_IO, OneUnknown_1Block)
{
    if (nodes != 1)
        return;
    decompose(6, 4, 2, 1, 1, 1);
    IO_t writer;
    writer.open("one_48B_1.h5");
    Vec_Dbl ref(48, 0.0);
    for (int n = 0; n < 48; ++n)
        ref[n] = n + 1;
    Decomp d(3);
    std::copy(local,  local + 3,  d.local.begin());
    std::copy(global, global + 3, d.global.begin());
    std::copy(offset, offset + 3, d.offset.begin());
    {
        Vec_Dbl data(num_local, 0);
        for (int k = 0; k < local[2]; ++k)
        {
            for (int j = 0; j < local[1]; ++j)
            {
                for (int i = 0; i < local[0]; ++i)
                {
                    data[l2l(i,j,k)] = ref[l2g(i,j,k)];
                }
            }
        }
        writer.write("mesh_data_CM", d, &data[0]);
    }
    {
        d.order = IO_t::ROW_MAJOR;
        Vec_Dbl data(num_local, 0);
        for (int k = 0; k < local[2]; ++k)
        {
            for (int j = 0; j < local[1]; ++j)
            {
                for (int i = 0; i < local[0]; ++i)
                {
                    int l = k + local[2] * (j + local[1] * (i));
                    int g = (k+offset[2]) + global[2] * (
                        (j+offset[1]) + global[1] * (i+offset[0]));
                    data[l] = ref[g] + 100.0;
                }
            }
        }
        writer.write("mesh_data_RM", d, &data[0]);
    }
    writer.close();
    profugus::global_barrier();
    if (node == 0)
    {
        open("one_48B_1.h5");
        Vec_Dbl d1, d2;
        read("mesh_data_RM", d2);
        read("mesh_data_CM", d1);
        EXPECT_EQ(48, d1.size());
        EXPECT_EQ(48, d2.size());
        EXPECT_VEC_EQ(ref, d1);
        for (int n = 0; n < 48; ++n)
        {
            EXPECT_EQ(ref[n] + 100.0, d2[n]);
        }
        close();
    }
}
TEST_F ( Parallel_Field_IO , OneUnknown_1Block ) { if ( nodes != 1 ) return ; decompose ( 6 , 4 , 2 , 1 , 1 , 1 ) ; IO_t writer ; writer . open ( " " ) ; Vec_Dbl ref ( 48 , 0.0 ) ; for ( int n = 0 ; n < 48 ; ++ n ) ref [ n ] = n + 1 ; Decomp d ( 3 ) ; std :: copy ( local , local + 3 , d . local . begin ( ) ) ; std :: copy ( global , global + 3 , d . global . begin ( ) ) ; std :: copy ( offset , offset + 3 , d . offset . begin ( ) ) ; { Vec_Dbl data ( num_local , 0 ) ; for ( int k = 0 ; k < local [ 2 ] ; ++ k ) { for ( int j = 0 ; j < local [ 1 ] ; ++ j ) { for ( int i = 0 ; i < local [ 0 ] ; ++ i ) { data [ l2l ( i , j , k ) ] = ref [ l2g ( i , j , k ) ] ; } } } writer . write ( " " , d , & data [ 0 ] ) ; } { d . order = IO_t :: ROW_MAJOR ; Vec_Dbl data ( num_local , 0 ) ; for ( int k = 0 ; k < local [ 2 ] ; ++ k ) { for ( int j = 0 ; j < local [ 1 ] ; ++ j ) { for ( int i = 0 ; i < local [ 0 ] ; ++ i ) { int l = k + local [ 2 ] * ( j + local [ 1 ] * ( i ) ) ; int g = ( k + offset [ 2 ] ) + global [ 2 ] * ( ( j + offset [ 1 ] ) + global [ 1 ] * ( i + offset [ 0 ] ) ) ; data [ l ] = ref [ g ] + 100.0 ; } } } writer . write ( " " , d , & data [ 0 ] ) ; } writer . close ( ) ; profugus :: global_barrier ( ) ; if ( node == 0 ) { open ( " " ) ; Vec_Dbl d1 , d2 ; read ( " " , d2 ) ; read ( " " , d1 ) ; EXPECT_EQ ( 48 , d1 . size ( ) ) ; EXPECT_EQ ( 48 , d2 . size ( ) ) ; EXPECT_VEC_EQ ( ref , d1 ) ; for ( int n = 0 ; n < 48 ; ++ n ) { EXPECT_EQ ( ref [ n ] + 100.0 , d2 [ n ] ) ; } close ( ) ; } }
This test assumes one unknown per mesh cell.
This test assumes one unknown per mesh cell .
// decompose a 6x4x2 mesh into 1 blocks // make a global reference field // make the decomposition (the decomposition is over (i,j,k)) // write using default COLUMN-MAJOR ORDER // write local data // write using ROW-MAJOR ORDER (we reorder the data to be ROW-MAJOR) // write local data // read data