Loading [MathJax]/extensions/tex2jax.js
Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

◆ main()

int main ( int  argc,
char **  argv 
)
Examples
TestExodusII.cpp.

Definition at line 35 of file TestExodusII.cpp.

36 { 37 #ifdef MOAB_HAVE_NETCDF 38  // Get MOAB instance 39  Interface* mb = new( std::nothrow ) Core; 40  if( NULL == mb ) return 1; 41  42  // Get the material set tag handle 43  Tag mtag; 44  ErrorCode rval; 45  const char* tag_nms[] = { "MATERIAL_SET", "DIRICHLET_SET", "NEUMANN_SET" }; 46  Range sets, set_ents; 47  48  // Load a file 49  if( argc == 1 ) 50  { 51  cout << "Running default case, loading " << test_file_name << endl; 52  cout << "Usage: " << argv[0] << " <filename>\n" << endl; 53  rval = mb->load_file( test_file_name.c_str() );MB_CHK_ERR( rval ); 54  } 55  else 56  { 57  rval = mb->load_file( argv[argc - 1] );MB_CHK_ERR( rval ); 58  cout << "Loaded mesh file: " << argv[argc - 1] << endl; 59  } 60  61  // Loop over set types 62  for( int i = 0; i < 3; i++ ) 63  { 64  rval = mb->tag_get_handle( tag_nms[i], 1, MB_TYPE_INTEGER, mtag );MB_CHK_ERR( rval ); 65  66  // Get all the sets of that type in the mesh 67  sets.clear(); 68  rval = mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &mtag, NULL, 1, sets );MB_CHK_ERR( rval ); 69  70  // Iterate over each set, getting entities 71  Range::iterator set_it; 72  for( set_it = sets.begin(); set_it != sets.end(); ++set_it ) 73  { 74  EntityHandle this_set = *set_it; 75  76  // Get the id for this set 77  int set_id; 78  rval = mb->tag_get_data( mtag, &this_set, 1, &set_id );MB_CHK_ERR( rval ); 79  80  // Get the entities in the set, recursively 81  rval = mb->get_entities_by_handle( this_set, set_ents, true );MB_CHK_ERR( rval ); 82  83  cout << tag_nms[i] << " " << set_id << " has " << set_ents.size() << " entities:" << endl; 84  85  // Print the entities contained in this set 86  set_ents.print( " " ); 87  set_ents.clear(); 88  } 89  } 90  91  delete mb; 92 #else 93  cout << " This test needs moab configured with netcdf \n"; 94 #endif 95  96  return 0; 97 }

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

Variable Documentation

◆ test_file_name

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

Definition at line 34 of file TestExodusII.cpp.

Referenced by main().