Mesh Oriented datABase  (version 5.6.0)
An array-based unstructured mesh library
TestExodusII.cpp File Reference
#include <iostream>
#include <memory>
#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)
 

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  std::unique_ptr< 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  MB_CHK_ERR( mb->load_file( test_file_name.c_str() ) );
54  }
55  else
56  {
57  MB_CHK_ERR( mb->load_file( argv[argc - 1] ) );
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  MB_CHK_ERR( mb->tag_get_handle( tag_nms[i], 1, MB_TYPE_INTEGER, mtag ) );
65 
66  // Get all the sets of that type in the mesh
67  sets.clear();
68  MB_CHK_ERR( mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &mtag, NULL, 1, sets ) );
69 
70  // Iterate over each set, getting entities
71  for( EntityHandle this_set : sets )
72  {
73  // Get the id for this set
74  int set_id;
75  MB_CHK_ERR( mb->tag_get_data( mtag, &this_set, 1, &set_id ) );
76 
77  // Get the entities in the set, recursively
78  MB_CHK_ERR( mb->get_entities_by_handle( this_set, set_ents, true ) );
79 
80  cout << tag_nms[i] << " " << set_id << " has " << set_ents.size() << " entities:" << endl;
81 
82  // Print the entities contained in this set
83  set_ents.print( " " );
84  set_ents.clear();
85  }
86  }
87 
88 #else
89  cout << " This test needs moab configured with netcdf \n";
90 #endif
91 
92  return 0;
93 }

References moab::Range::clear(), 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(), and test_file_name.