MOAB: Mesh Oriented datABase  (version 5.5.0)
test_exo.cpp File Reference
#include "moab/Defines.h"
#include "moab/Core.hpp"
#include "ReadWriteExoII.hpp"
#include "moab/_MBSet.hpp"
#include <iostream>
+ Include dependency graph for test_exo.cpp:

Go to the source code of this file.

Functions

std::ostream & operator<< (std::ostream &out, const std::vector< int > &v)
 
int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 31 of file test_exo.cpp.

32 {
33  // check for file name on command line
34  if( 2 != argc )
35  {
36  std::cout << "Usage: " << argv[0] << " <exoII_file_name>" << std::endl;
37  return 1;
38  }
39 
40  Core mdb;
41  ReadWriteExoII reader( &mdb );
42  ErrorCode result = reader.load_file( argv[1], NULL );
43 
44  std::cout << "Result of reading file = " << ( MB_FAILURE == result ? "FAILURE." : "SUCCESS." ) << std::endl;
45 
46  // print some data about the mesh
47  int num_nodes = mdb.total_num_nodes();
48  int num_elements = mdb.total_num_elements();
49  std::cout << "Total number of nodes, elements read = " << num_nodes << ", " << num_elements << std::endl;
50 
51  // get the nodeset meshsets and blocks
52  std::vector< MB_MBSet* > blocks, nodesets, sidesets;
53  std::vector< int > block_ids, nodeset_ids, sideset_ids;
54  const std::set< MB_MBSet* >& gms = MB_MBSet::GlobalMBSets();
55 
56  std::set< MB_MBSet* >::const_iterator this_it = gms.begin(), end_it = MB_MBSet::GlobalMBSets().end();
57  MB_MBSet* this_meshset;
58  int bc_tag;
59  for( ; this_it != end_it; ++this_it )
60  {
61  // get the next set
62  this_meshset = *this_it;
63 
64  bc_tag = reader.get_block_id( this_meshset );
65  if( -1 != bc_tag )
66  {
67  blocks.push_back( this_meshset );
68  block_ids.push_back( bc_tag );
69  }
70 
71  // same for nodeset tag
72  bc_tag = reader.get_nodeset_id( this_meshset );
73  if( -1 != bc_tag )
74  {
75  nodesets.push_back( this_meshset );
76  nodeset_ids.push_back( bc_tag );
77  }
78 
79  // same for sideset tag
80  bc_tag = reader.get_sideset_id( this_meshset );
81  if( -1 != bc_tag )
82  {
83  sidesets.push_back( this_meshset );
84  sideset_ids.push_back( bc_tag );
85  }
86  }
87 
88  // std::vector<int>::iterator set_it;
89  std::cout << "Block numbers read: " << std::endl;
90  if( !blocks.empty() )
91  std::cout << block_ids << std::endl;
92  else
93  std::cout << "(no blocks)" << std::endl;
94 
95  std::cout << "Nodeset numbers read: " << std::endl;
96  if( !nodesets.empty() )
97  std::cout << nodeset_ids << std::endl;
98  else
99  std::cout << "(no nodesets)" << std::endl;
100 
101  std::cout << "Sideset numbers read: " << std::endl;
102  if( !sidesets.empty() )
103  std::cout << sideset_ids << std::endl;
104  else
105  std::cout << "(no sidesets)" << std::endl;
106 }

References ErrorCode.

◆ operator<<()

std::ostream& operator<< ( std::ostream &  out,
const std::vector< int > &  v 
)

Definition at line 25 of file test_exo.cpp.

26 {
27  std::copy( v.begin(), v.end(), std::ostream_iterator< int >( std::cout, " " ) );
28  return out;
29 }