MOAB: Mesh Oriented datABase  (version 5.2.1)
read_mpas_nc.cpp File Reference
#include "TestUtil.hpp"
#include "moab/Core.hpp"
#include "moab/ReadUtilIface.hpp"
#include "MBTagConventions.hpp"
+ Include dependency graph for read_mpas_nc.cpp:

Go to the source code of this file.

Functions

void test_read_all ()
void test_read_onevar ()
void test_read_onetimestep ()
void test_read_nomesh ()
void test_read_novars ()
void test_read_no_mixed_elements ()
void test_read_no_edges ()
void test_gather_onevar ()
void get_options (std::string &opts)
int main (int argc, char *argv[])

Variables

std::string example = "/io/mpasx1.642.t.2.nc"
const double eps = 1e-20

Function Documentation

void get_options ( std::string &  opts)
int main ( int  argc,
char *  argv[] 
)

Definition at line 28 of file read_mpas_nc.cpp.

References moab::fail(), RUN_TEST, test_gather_onevar(), test_read_all(), test_read_no_edges(), test_read_no_mixed_elements(), test_read_nomesh(), test_read_novars(), test_read_onetimestep(), and test_read_onevar().

{
    int result = 0;

#ifdef MOAB_HAVE_MPI
    int fail = MPI_Init( &argc, &argv );
    if( fail ) return 1;
#else
    argv[0]   = argv[argc - argc];  // To remove the warnings in serial mode about unused variables
#endif

    result += RUN_TEST( test_read_all );
    result += RUN_TEST( test_read_onevar );
    result += RUN_TEST( test_read_onetimestep );
    result += RUN_TEST( test_read_nomesh );
    result += RUN_TEST( test_read_novars );
    result += RUN_TEST( test_read_no_mixed_elements );
    result += RUN_TEST( test_read_no_edges );
    result += RUN_TEST( test_gather_onevar );

#ifdef MOAB_HAVE_MPI
    fail = MPI_Finalize();
    if( fail ) return 1;
#endif

    return result;
}
void test_read_all ( )

Definition at line 330 of file read_mpas_nc.cpp.

References CHECK_EQUAL, CHECK_ERR, CHECK_REAL_EQUAL, eps, example, get_options(), moab::ParallelComm::get_pcomm(), MB_TYPE_DOUBLE, MBPOLYGON, moab::ParallelComm::proc_config(), moab::ProcConfig::proc_size(), moab::Range::psize(), and moab::Range::size().

Referenced by main().

{
    Core moab;
    Interface& mb = moab;

    std::string opts;
    get_options( opts );

    // Read mesh with no mixed elements and read all variables at all timesteps
    opts += ";NO_MIXED_ELEMENTS";
    ErrorCode rval = mb.load_file( example.c_str(), NULL, opts.c_str() );CHECK_ERR( rval );

#ifdef MOAB_HAVE_MPI
    ParallelComm* pcomm = ParallelComm::get_pcomm( &mb, 0 );
    int procs           = pcomm->proc_config().proc_size();
#else
    int procs = 1;
#endif

    // Make check runs this test on one processor
    if( 1 == procs )
    {
        // Check ke tags
        Tag ke_tag0, ke_tag1;
        rval = mb.tag_get_handle( "ke0", 1, MB_TYPE_DOUBLE, ke_tag0 );CHECK_ERR( rval );
        rval = mb.tag_get_handle( "ke1", 1, MB_TYPE_DOUBLE, ke_tag1 );CHECK_ERR( rval );

        // Get cells (12 pentagons and 630 hexagons)
        Range cells;
        rval = mb.get_entities_by_type( 0, MBPOLYGON, cells );CHECK_ERR( rval );
        CHECK_EQUAL( (size_t)642, cells.size() );
        // Only one group of cells (pentagons are padded to hexagons,
        // e.g. connectivity [1 2 3 4 5] => [1 2 3 4 5 5])
        CHECK_EQUAL( (size_t)1, cells.psize() );

        // Check ke tag values on 4 cells: first pentagon, last pentagon,
        // first hexagon, and last hexagon
        EntityHandle cell_ents[] = { cells[0], cells[11], cells[12], cells[641] };
        double ke0_val[4];
        rval = mb.tag_get_data( ke_tag0, cell_ents, 4, ke0_val );CHECK_ERR( rval );
        CHECK_REAL_EQUAL( 15.001, ke0_val[0], eps );
        CHECK_REAL_EQUAL( 15.012, ke0_val[1], eps );
        CHECK_REAL_EQUAL( 16.013, ke0_val[2], eps );
        CHECK_REAL_EQUAL( 16.642, ke0_val[3], eps );
        double ke1_val[4];
        rval = mb.tag_get_data( ke_tag1, cell_ents, 4, ke1_val );CHECK_ERR( rval );
        CHECK_REAL_EQUAL( 25.001, ke1_val[0], eps );
        CHECK_REAL_EQUAL( 25.012, ke1_val[1], eps );
        CHECK_REAL_EQUAL( 26.013, ke1_val[2], eps );
        CHECK_REAL_EQUAL( 26.642, ke1_val[3], eps );
    }
}
void test_read_nomesh ( )
void test_read_novars ( )
void test_read_onevar ( )

Variable Documentation

const double eps = 1e-20

Definition at line 26 of file read_mpas_nc.cpp.

std::string example = "/io/mpasx1.642.t.2.nc"

Definition at line 8 of file read_mpas_nc.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines