Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
TestExodusII.cpp File Reference
#include <iostream>
#include "moab/Core.hpp"
+ Include dependency graph for TestExodusII.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Variables

string test_file_name = string( MESH_DIR ) + string( "/mbtest2.g" )

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 35 of file TestExodusII.cpp.

References moab::Range::begin(), moab::Range::clear(), moab::Range::end(), ErrorCode, moab::Interface::get_entities_by_handle(), moab::Interface::get_entities_by_type_and_tag(), moab::Interface::load_file(), mb, MB_CHK_ERR, MB_TYPE_INTEGER, MBENTITYSET, moab::Range::print(), moab::Range::size(), moab::Interface::tag_get_data(), moab::Interface::tag_get_handle(), tag_nms, and test_file_name.

{
#ifdef MOAB_HAVE_NETCDF
    // Get MOAB instance
    Interface* mb = new( std::nothrow ) Core;
    if( NULL == mb ) return 1;

    // Get the material set tag handle
    Tag mtag;
    ErrorCode rval;
    const char* tag_nms[] = { "MATERIAL_SET", "DIRICHLET_SET", "NEUMANN_SET" };
    Range sets, set_ents;

    // Load a file
    if( argc == 1 )
    {
        cout << "Running default case, loading " << test_file_name << endl;
        cout << "Usage: " << argv[0] << " <filename>\n" << endl;
        rval = mb->load_file( test_file_name.c_str() );MB_CHK_ERR( rval );
    }
    else
    {
        rval = mb->load_file( argv[argc - 1] );MB_CHK_ERR( rval );
        cout << "Loaded mesh file: " << argv[argc - 1] << endl;
    }

    // Loop over set types
    for( int i = 0; i < 3; i++ )
    {
        rval = mb->tag_get_handle( tag_nms[i], 1, MB_TYPE_INTEGER, mtag );MB_CHK_ERR( rval );

        // Get all the sets of that type in the mesh
        sets.clear();
        rval = mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &mtag, NULL, 1, sets );MB_CHK_ERR( rval );

        // Iterate over each set, getting entities
        Range::iterator set_it;
        for( set_it = sets.begin(); set_it != sets.end(); ++set_it )
        {
            EntityHandle this_set = *set_it;

            // Get the id for this set
            int set_id;
            rval = mb->tag_get_data( mtag, &this_set, 1, &set_id );MB_CHK_ERR( rval );

            // Get the entities in the set, recursively
            rval = mb->get_entities_by_handle( this_set, set_ents, true );MB_CHK_ERR( rval );

            cout << tag_nms[i] << " " << set_id << " has " << set_ents.size() << " entities:" << endl;

            // Print the entities contained in this set
            set_ents.print( "   " );
            set_ents.clear();
        }
    }

    delete mb;
#else
    cout << " This test needs moab configured with netcdf \n";
#endif

    return 0;
}

Variable Documentation

string test_file_name = string( MESH_DIR ) + string( "/mbtest2.g" )

Definition at line 34 of file TestExodusII.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines