![]() |
Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
#include "moab/Core.hpp"
#include "moab/Interface.hpp"
#include "moab/Range.hpp"
#include "MBTagConventions.hpp"
#include <iostream>
Go to the source code of this file.
Defines | |
#define | MESH_DIR "." |
Functions | |
int | main (int argc, char **argv) |
Variables | |
string | test_file_name = string( MESH_DIR ) + string( "/hex01.vtk" ) |
const char * | tag_nms [] = { MATERIAL_SET_TAG_NAME, DIRICHLET_SET_TAG_NAME, NEUMANN_SET_TAG_NAME } |
#define MESH_DIR "." |
Definition at line 20 of file SetsNTags.cpp.
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 28 of file SetsNTags.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.
{
// Get the material set tag handle
Tag mtag;
ErrorCode rval;
Range sets, set_ents;
// Get MOAB instance
Interface* mb = new( std::nothrow ) Core;
if( NULL == mb ) return 1;
// Need option handling here for input filename
if( argc > 1 )
{
// User has input a mesh file
test_file_name = argv[1];
}
// Load a file
rval = mb->load_file( test_file_name.c_str() );MB_CHK_ERR( rval );
// Loop over set types
for( int i = 0; i < 3; i++ )
{
// Get the tag handle for this tag name; tag should already exist (it was created during
// file read)
rval = mb->tag_get_handle( tag_nms[i], 1, MB_TYPE_INTEGER, mtag );MB_CHK_ERR( rval );
// Get all the sets having that tag (with any value for that tag)
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 the entities and printing them
Range::iterator set_it;
for( set_it = sets.begin(); set_it != sets.end(); ++set_it )
{
// Get the id for this set
int set_id;
rval = mb->tag_get_data( mtag, &( *set_it ), 1, &set_id );MB_CHK_ERR( rval );
// Get the entities in the set, recursively
rval = mb->get_entities_by_handle( *set_it, set_ents, true );MB_CHK_ERR( rval );
cout << tag_nms[i] << " " << set_id << " has " << set_ents.size() << " entities:" << endl;
set_ents.print( " " );
set_ents.clear();
}
}
delete mb;
return 0;
}
const char* tag_nms[] = { MATERIAL_SET_TAG_NAME, DIRICHLET_SET_TAG_NAME, NEUMANN_SET_TAG_NAME } |
Definition at line 26 of file SetsNTags.cpp.
Referenced by main().
string test_file_name = string( MESH_DIR ) + string( "/hex01.vtk" ) |
Definition at line 23 of file SetsNTags.cpp.