![]() |
Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
00001 /** @example HelloMOAB.cpp
00002 * Description: read a mesh, get the entities.\n
00003 * HelloMOAB is a simple test file which is used to read meshes from VTK file and test how many
00004 * entities there are.\n
00005 *
00006 * To run: ./HelloMOAB [meshfile]\n
00007 * (default values can run if users don't specify a mesh file)
00008 */
00009
00010 #include "moab/Core.hpp"
00011 #include
00012
00013 using namespace moab;
00014 using namespace std;
00015
00016 #ifndef MESH_DIR
00017 #define MESH_DIR "."
00018 #endif
00019
00020 // Note: change the file name below to test a trivial "No such file or directory" error
00021 string test_file_name = string( MESH_DIR ) + string( "/3k-tri-sphere.vtk" );
00022
00023 int main( int argc, char** argv )
00024 {
00025 // Get MOAB instance
00026 Interface* mb = new( std::nothrow ) Core;
00027 if( NULL == mb ) return 1;
00028
00029 // Need option handling here for input filename
00030 if( argc > 1 )
00031 {
00032 // User has input a mesh file
00033 test_file_name = argv[1];
00034 }
00035
00036 // Load the mesh from vtk file
00037 ErrorCode rval = mb->load_mesh( test_file_name.c_str() );MB_CHK_ERR( rval );
00038
00039 // Get verts entities, by type
00040 Range verts;
00041 rval = mb->get_entities_by_type( 0, MBVERTEX, verts );MB_CHK_ERR( rval );
00042
00043 // Get edge entities, by type
00044 Range edges;
00045 rval = mb->get_entities_by_type( 0, MBEDGE, edges );MB_CHK_ERR( rval );
00046
00047 // Get faces, by dimension, so we stay generic to entity type
00048 Range faces;
00049 rval = mb->get_entities_by_dimension( 0, 2, faces );MB_CHK_ERR( rval );
00050
00051 // Get regions, by dimension, so we stay generic to entity type
00052 Range elems;
00053 rval = mb->get_entities_by_dimension( 0, 3, elems );MB_CHK_ERR( rval );
00054
00055 // Output the number of entities
00056 cout << "Number of vertices is " << verts.size() << endl;
00057 cout << "Number of edges is " << edges.size() << endl;
00058 cout << "Number of faces is " << faces.size() << endl;
00059 cout << "Number of elements is " << elems.size() << endl;
00060
00061 delete mb;
00062
00063 return 0;
00064 }