Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
HelloMOAB.cpp File Reference
#include "moab/Core.hpp"
#include <iostream>
+ Include dependency graph for HelloMOAB.cpp:

Go to the source code of this file.

Macros

#define MESH_DIR   "."
 

Functions

int main (int argc, char **argv)
 

Variables

string test_file_name = string( MESH_DIR ) + string( "/3k-tri-sphere.vtk" )
 

Macro Definition Documentation

◆ MESH_DIR

#define MESH_DIR   "."
Examples
HelloMOAB.cpp.

Definition at line 17 of file HelloMOAB.cpp.

Function Documentation

◆ main()

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

Definition at line 23 of file HelloMOAB.cpp.

24 {
25  // Get MOAB instance
26  Interface* mb = new( std::nothrow ) Core;
27  if( NULL == mb ) return 1;
28 
29  // Need option handling here for input filename
30  if( argc > 1 )
31  {
32  // User has input a mesh file
33  test_file_name = argv[1];
34  }
35 
36  // Load the mesh from vtk file
37  ErrorCode rval = mb->load_mesh( test_file_name.c_str() );MB_CHK_ERR( rval );
38 
39  // Get verts entities, by type
40  Range verts;
41  rval = mb->get_entities_by_type( 0, MBVERTEX, verts );MB_CHK_ERR( rval );
42 
43  // Get edge entities, by type
44  Range edges;
45  rval = mb->get_entities_by_type( 0, MBEDGE, edges );MB_CHK_ERR( rval );
46 
47  // Get faces, by dimension, so we stay generic to entity type
48  Range faces;
49  rval = mb->get_entities_by_dimension( 0, 2, faces );MB_CHK_ERR( rval );
50 
51  // Get regions, by dimension, so we stay generic to entity type
52  Range elems;
53  rval = mb->get_entities_by_dimension( 0, 3, elems );MB_CHK_ERR( rval );
54 
55  // Output the number of entities
56  cout << "Number of vertices is " << verts.size() << endl;
57  cout << "Number of edges is " << edges.size() << endl;
58  cout << "Number of faces is " << faces.size() << endl;
59  cout << "Number of elements is " << elems.size() << endl;
60 
61  delete mb;
62 
63  return 0;
64 }

References ErrorCode, moab::Core::get_entities_by_dimension(), moab::Core::get_entities_by_type(), moab::Core::load_mesh(), mb, MB_CHK_ERR, MBEDGE, MBVERTEX, moab::Range::size(), and test_file_name.

Variable Documentation

◆ test_file_name

string test_file_name = string( MESH_DIR ) + string( "/3k-tri-sphere.vtk" )
Examples
HelloMOAB.cpp.

Definition at line 21 of file HelloMOAB.cpp.

Referenced by main().