MOAB: Mesh Oriented datABase  (version 5.2.1)
mbmem.cpp
Go to the documentation of this file.
00001 #include "moab/Core.hpp"
00002 #include "moab/Range.hpp"
00003 #include "moab/CN.hpp"
00004 
00005 #include <iostream>
00006 #include <iomanip>
00007 #include <sstream>
00008 #include <string>
00009 #include <cstdio>
00010 #include <cstdlib>
00011 
00012 #ifndef _WIN32
00013 #include <sys/times.h>
00014 #include <sys/resource.h>
00015 #include <unistd.h>
00016 #endif
00017 
00018 static void usage( const char* argv0, bool help = false )
00019 {
00020     std::ostream& str = help ? std::cout : std::cerr;
00021     str << "Usage: " << argv0 << " [-H|-b|-k|-m] <filename> [<filename> ...]" << std::endl
00022         << "       " << argv0 << " [-H|-b|-k|-m] -T" << std::endl;
00023     if( !help )
00024     {
00025         str << "       " << argv0 << " -h" << std::endl;
00026         std::exit( 1 );
00027     }
00028 
00029     std::cerr << "  -H : human readable units" << std::endl
00030               << "  -b : bytes" << std::endl
00031               << "  -k : kilobytes (1 kB == 1024 bytes)" << std::endl
00032               << "  -m : megabytes (1 MB == 1024 kB)" << std::endl
00033               << "  -g : gigabytes (1 GB == 1024 MB)" << std::endl
00034               << "  -T : test mode" << std::endl
00035               << std::endl;
00036     std::exit( 0 );
00037 }
00038 
00039 enum Units
00040 {
00041     HUMAN,
00042     BYTES,
00043     KILOBYTES,
00044     MEGABYTES,
00045     GIGABYTES
00046 };
00047 Units UNITS = HUMAN;
00048 
00049 // The core functionality of this example
00050 static void print_memory_stats( moab::Interface& mb, bool per_type = true, bool per_tag = true, bool totals = true,
00051                                 bool sysstats = true );
00052 
00053 // Generate a series of meshes for testing
00054 static void do_test_mode();
00055 
00056 // main routine: read any specified files and call print_memory_stats
00057 int main( int argc, char* argv[] )
00058 {
00059     moab::ErrorCode rval;
00060     bool no_more_flags = false;
00061     bool test_mode     = false;
00062     std::vector< int > input_file_list;
00063 
00064     // load each file specified on command line
00065     for( int i = 1; i < argc; ++i )
00066     {
00067         if( !no_more_flags && argv[i][0] == '-' )
00068         {
00069             if( !strcmp( argv[i], "-H" ) )
00070                 UNITS = HUMAN;
00071             else if( !strcmp( argv[i], "-b" ) )
00072                 UNITS = BYTES;
00073             else if( !strcmp( argv[i], "-k" ) )
00074                 UNITS = KILOBYTES;
00075             else if( !strcmp( argv[i], "-m" ) )
00076                 UNITS = MEGABYTES;
00077             else if( !strcmp( argv[i], "-g" ) )
00078                 UNITS = GIGABYTES;
00079             else if( !strcmp( argv[i], "-T" ) )
00080                 test_mode = true;
00081             else if( !strcmp( argv[i], "-h" ) )
00082                 usage( argv[0], true );
00083             else if( !strcmp( argv[i], "--" ) )
00084                 no_more_flags = true;
00085             else
00086             {
00087                 std::cerr << argv[0] << ": Invalid flag: \"" << argv[i] << "\"." << std::endl << std::endl;
00088                 usage( argv[0] );
00089             }
00090         }
00091         else
00092         {
00093             input_file_list.push_back( i );
00094         }
00095     }
00096 
00097     if( test_mode )
00098     {
00099         do_test_mode();
00100         if( input_file_list.empty() ) return 0;
00101     }
00102 
00103     moab::Core mbcore;
00104     moab::Interface& mb = mbcore;
00105     for( std::vector< int >::iterator it = input_file_list.begin(); it != input_file_list.end(); ++it )
00106     {
00107         rval = mb.load_file( argv[*it] );
00108 
00109         // if file load failed, print some info and exit
00110         if( moab::MB_SUCCESS != rval )
00111         {
00112             std::string message;
00113             mb.get_last_error( message );
00114             std::cerr << mb.get_error_string( rval ) << ": " << message << std::endl
00115                       << argv[*it] << ": Failed to read file." << std::endl;
00116             return 1;
00117         }
00118 
00119         std::cout << "Loaded file: " << argv[*it] << std::endl;
00120     }
00121 
00122     // print summary of MOAB's memory use
00123     print_memory_stats( mb );
00124     return 0;
00125 }
00126 
00127 // struct to store memory stats
00128 struct MemStats
00129 {
00130     unsigned long long total_storage;
00131     unsigned long long total_amortized;
00132     unsigned long long entity_storage;
00133     unsigned long long entity_amortized;
00134     unsigned long long adjacency_storage;
00135     unsigned long long adjacency_amortized;
00136     unsigned long long tag_storage;
00137     unsigned long long tag_amortized;
00138 };
00139 
00140 // test if MemStats object indicates no memory
00141 static bool is_zero( const MemStats& stats );
00142 
00143 // populdate a MemStats structg by calling
00144 // moab::Interface::estimated_memory_use
00145 static void get_mem_stats( moab::Interface& mb, MemStats& data, moab::EntityType type = moab::MBMAXTYPE );
00146 
00147 // Formatted string representation of memory size value
00148 static std::string memstr( unsigned long long val );
00149 
00150 // Get string describing tag data type
00151 static std::string tag_type_string( moab::Interface& mb, moab::Tag tag );
00152 
00153 // Get string representation of tag storage type
00154 static std::string tag_storage_string( moab::Interface& mb, moab::Tag tag );
00155 
00156 // Center
00157 static std::string center( const char* str, size_t width );
00158 
00159 void print_memory_stats( moab::Interface& mb, bool per_type, bool per_tag, bool totals, bool sysstats )
00160 {
00161     moab::ErrorCode rval;
00162     const char ANON_TAG_NAME[]   = "(anonymous)";
00163     const int TYPE_WIDTH         = 10;
00164     const int MEM_WIDTH          = 7;
00165     const int MEM2_WIDTH         = 2 * MEM_WIDTH + 1;
00166     const int MIN_TAG_NAME_WIDTH = strlen( ANON_TAG_NAME );
00167     const int DTYPE_WIDTH        = 12;
00168     const int STORAGE_WIDTH      = 8;
00169 
00170     // per-entity-type table header
00171     MemStats stats;
00172 
00173     if( per_type )
00174     {
00175 
00176         std::cout.fill( ' ' );
00177         std::cout << std::left << std::setw( TYPE_WIDTH ) << "Type" << ' ' << center( "Total", MEM2_WIDTH ) << ' '
00178                   << center( "Entity", MEM2_WIDTH ) << ' ' << center( "Adjacency", MEM2_WIDTH ) << ' '
00179                   << center( "Tag", MEM2_WIDTH ) << ' ' << std::endl
00180                   << std::setw( TYPE_WIDTH ) << " ";
00181         for( int i = 0; i < 4; ++i )
00182             std::cout << ' ' << std::left << std::setw( MEM_WIDTH ) << "Used" << ' ' << std::left
00183                       << std::setw( MEM_WIDTH ) << "Alloc";
00184         std::cout << std::endl;
00185         std::cout.fill( '-' );
00186         std::cout << std::setw( TYPE_WIDTH ) << '-';
00187         for( int i = 0; i < 8; ++i )
00188             std::cout << ' ' << std::setw( MEM_WIDTH ) << '-';
00189         std::cout.fill( ' ' );
00190         std::cout << std::endl;
00191 
00192         // per-entity-type memory use
00193         for( moab::EntityType t = moab::MBVERTEX; t != moab::MBMAXTYPE; ++t )
00194         {
00195             get_mem_stats( mb, stats, t );
00196             if( is_zero( stats ) ) continue;  // skip types with no allocated memory
00197 
00198             std::cout << std::left << std::setw( TYPE_WIDTH ) << moab::CN::EntityTypeName( t ) << ' ' << std::right
00199                       << std::setw( MEM_WIDTH ) << memstr( stats.total_storage ) << ' ' << std::right
00200                       << std::setw( MEM_WIDTH ) << memstr( stats.total_amortized ) << ' ' << std::right
00201                       << std::setw( MEM_WIDTH ) << memstr( stats.entity_storage ) << ' ' << std::right
00202                       << std::setw( MEM_WIDTH ) << memstr( stats.entity_amortized ) << ' ' << std::right
00203                       << std::setw( MEM_WIDTH ) << memstr( stats.adjacency_storage ) << ' ' << std::right
00204                       << std::setw( MEM_WIDTH ) << memstr( stats.adjacency_amortized ) << ' ' << std::right
00205                       << std::setw( MEM_WIDTH ) << memstr( stats.tag_storage ) << ' ' << std::right
00206                       << std::setw( MEM_WIDTH ) << memstr( stats.tag_amortized ) << std::endl;
00207         }
00208     }  // end per_type
00209 
00210     if( per_tag )
00211     {
00212         // get list of tags
00213         std::vector< moab::Tag > tags;
00214         std::vector< moab::Tag >::const_iterator ti;
00215         mb.tag_get_tags( tags );
00216 
00217         // figure out required field with to fit longest tag name
00218         unsigned maxlen = MIN_TAG_NAME_WIDTH;
00219         for( ti = tags.begin(); ti != tags.end(); ++ti )
00220         {
00221             std::string name;
00222             rval = mb.tag_get_name( *ti, name );
00223             if( moab::MB_SUCCESS != rval ) continue;
00224             if( name.size() > maxlen ) maxlen = name.size();
00225         }
00226 
00227         // print header for per-tag data
00228         if( !tags.empty() )
00229         {
00230             std::cout.fill( ' ' );
00231             std::cout << std::endl
00232                       << std::left << std::setw( maxlen ) << "Tag Name" << ' ' << std::left << std::setw( DTYPE_WIDTH )
00233                       << "Type" << ' ' << std::left << std::setw( STORAGE_WIDTH ) << "Storage" << ' ' << std::left
00234                       << std::setw( MEM_WIDTH ) << "Used" << ' ' << std::left << std::setw( MEM_WIDTH ) << "Alloc"
00235                       << std::endl;
00236             std::cout.fill( '-' );
00237             std::cout << std::setw( maxlen ) << '-' << ' ' << std::setw( DTYPE_WIDTH ) << '-' << ' '
00238                       << std::setw( STORAGE_WIDTH ) << '-' << ' ' << std::setw( MEM_WIDTH ) << '-' << ' '
00239                       << std::setw( MEM_WIDTH ) << '-' << std::endl;
00240             std::cout.fill( ' ' );
00241         }
00242 
00243         // print per-tag memory use
00244         for( ti = tags.begin(); ti != tags.end(); ++ti )
00245         {
00246             std::string name;
00247             rval = mb.tag_get_name( *ti, name );
00248             if( moab::MB_SUCCESS != rval || name.empty() ) name = ANON_TAG_NAME;
00249 
00250             unsigned long long occupied, allocated;
00251             mb.estimated_memory_use( 0, 0, 0, 0, 0, 0, 0, 0, &*ti, 1, &occupied, &allocated );
00252 
00253             std::cout << std::left << std::setw( maxlen ) << name << ' ' << std::right << std::setw( DTYPE_WIDTH )
00254                       << tag_type_string( mb, *ti ) << ' ' << std::right << std::setw( STORAGE_WIDTH )
00255                       << tag_storage_string( mb, *ti ) << ' ' << std::right << std::setw( MEM_WIDTH )
00256                       << memstr( occupied ) << ' ' << std::right << std::setw( MEM_WIDTH ) << memstr( allocated )
00257                       << std::endl;
00258         }
00259     }  // end per_tag
00260 
00261     if( totals )
00262     {
00263         // print summary of overall memory use
00264         get_mem_stats( mb, stats );
00265         std::cout << std::endl
00266                   << "TOTAL: (Used/Allocated)" << std::endl
00267                   << "memory:    " << memstr( stats.total_storage ) << "/" << memstr( stats.total_amortized )
00268                   << std::endl
00269                   << "entity:    " << memstr( stats.entity_storage ) << "/" << memstr( stats.entity_amortized )
00270                   << std::endl
00271                   << "adjacency: " << memstr( stats.adjacency_storage ) << "/" << memstr( stats.adjacency_amortized )
00272                   << std::endl
00273                   << "tag:       " << memstr( stats.tag_storage ) << "/" << memstr( stats.tag_amortized ) << std::endl
00274                   << std::endl;
00275 
00276     }  // end totals
00277 
00278     if( sysstats )
00279     {
00280         std::FILE* filp = std::fopen( "/proc/self/stat", "r" );
00281         unsigned long long vsize;
00282         long rss;
00283         if( filp && 2 == std::fscanf( filp,
00284                                       "%*d "   // pid
00285                                       "%*s "   // comm
00286                                       "%*c "   // state
00287                                       "%*d "   // ppid
00288                                       "%*d "   // pgrp
00289                                       "%*d "   // session
00290                                       "%*d "   // tty_nr
00291                                       "%*d "   // tpgid
00292                                       "%*u "   // flags
00293                                       "%*u "   // minflt
00294                                       "%*u "   // cminflt
00295                                       "%*u "   // majflt
00296                                       "%*u "   // cmajflt
00297                                       "%*u "   // utime
00298                                       "%*u "   // stime
00299                                       "%*d "   // cutime
00300                                       "%*d "   // cstime
00301                                       "%*d "   // priority
00302                                       "%*d "   // nice
00303                                       "%*d "   // num_threads
00304                                       "%*d "   // itrealvalue
00305                                       "%*u "   // starttime
00306                                       "%llu "  // vsize
00307                                       "%ld",   // rss
00308                                       &vsize, &rss ) )
00309         {
00310 #ifndef _WIN32
00311             long long tmprss = rss * getpagesize();
00312 #endif
00313             std::cout << std::endl
00314                       << "SYSTEM:" << std::endl
00315                       << "Virtual memory:    " << memstr( vsize )
00316 #ifndef _WIN32
00317                       << std::endl
00318                       << "Resident set size: " << memstr( tmprss )
00319 #endif
00320                       << std::endl;
00321         }
00322         else
00323         {
00324 #ifndef _WIN32
00325             struct rusage sysdata;
00326             if( getrusage( RUSAGE_SELF, &sysdata ) ) { std::cerr << "getrusage failed" << std::endl; }
00327             else
00328             {
00329                 rss              = sysdata.ru_maxrss;
00330                 long long tmprss = rss * getpagesize();
00331                 std::cerr << std::endl
00332                           << "SYSTEM:" << std::endl
00333                           << "Resident set size: " << memstr( tmprss ) << std::endl;
00334             }
00335 #endif
00336         }
00337         if( filp ) fclose( filp );
00338     }  // end sysstats
00339 }
00340 
00341 bool is_zero( const MemStats& stats )
00342 {
00343     return stats.total_amortized == 0;
00344 }
00345 
00346 void get_mem_stats( moab::Interface& mb, MemStats& data, moab::EntityType type )
00347 {
00348     if( type != moab::MBMAXTYPE )
00349     {
00350         moab::Range range;
00351         mb.get_entities_by_type( 0, type, range );
00352         mb.estimated_memory_use( range, &data.total_storage, &data.total_amortized, &data.entity_storage,
00353                                  &data.entity_amortized, &data.adjacency_storage, &data.adjacency_amortized, 0, 0,
00354                                  &data.tag_storage, &data.tag_amortized );
00355     }
00356     else
00357     {
00358         mb.estimated_memory_use( 0, 0, &data.total_storage, &data.total_amortized, &data.entity_storage,
00359                                  &data.entity_amortized, &data.adjacency_storage, &data.adjacency_amortized, 0, 0,
00360                                  &data.tag_storage, &data.tag_amortized );
00361     }
00362 }
00363 
00364 // rounded division
00365 static unsigned long long rdiv( unsigned long long num, unsigned long long den )
00366 {
00367     return ( num + den / 2 ) / den;
00368 }
00369 
00370 std::string memstr( unsigned long long val )
00371 {
00372     const unsigned long long kb = 1024;
00373     const unsigned long long mb = kb * kb;
00374     const unsigned long long gb = kb * mb;
00375     const unsigned long long tb = kb * gb;
00376 
00377     std::ostringstream s;
00378     if( UNITS == HUMAN )
00379     {
00380         if( val >= 10 * tb )
00381             s << rdiv( val, tb ) << "TB";
00382         else if( val >= 10 * gb )
00383             s << rdiv( val, gb ) << "GB";
00384         else if( val >= 10 * mb )
00385             s << rdiv( val, mb ) << "MB";
00386         else if( val >= 10 * kb )
00387             s << rdiv( val, kb ) << "kB";
00388         else if( val > 0 )
00389             s << val << " B";
00390         else
00391             s << "0  ";
00392     }
00393     else
00394     {
00395         unsigned long long den = 1;
00396         switch( UNITS )
00397         {
00398             case BYTES:
00399                 den = 1;
00400                 break;
00401             case KILOBYTES:
00402                 den = kb;
00403                 break;
00404             case MEGABYTES:
00405                 den = mb;
00406                 break;
00407             case GIGABYTES:
00408                 den = gb;
00409                 break;
00410             case HUMAN:
00411                 break;  // handled above, list here to suppress warning
00412         }
00413 
00414         s << rdiv( val, den );
00415     }
00416     return s.str();
00417 }
00418 
00419 std::string tag_type_string( moab::Interface& mb, moab::Tag tag )
00420 {
00421     moab::ErrorCode rval;
00422     std::ostringstream s;
00423 
00424     moab::DataType type;
00425     rval = mb.tag_get_data_type( tag, type );
00426     if( moab::MB_SUCCESS != rval ) return std::string();
00427 
00428     int typesize;
00429     std::string typestr;
00430     switch( type )
00431     {
00432         case moab::MB_TYPE_INTEGER:
00433             typestr  = "int";
00434             typesize = sizeof( int );
00435             break;
00436         case moab::MB_TYPE_DOUBLE:
00437             typestr  = "double";
00438             typesize = sizeof( double );
00439             break;
00440         case moab::MB_TYPE_HANDLE:
00441             typestr  = "handle";
00442             typesize = sizeof( moab::EntityHandle );
00443             break;
00444         case moab::MB_TYPE_BIT:
00445             typesize = 1;
00446             typestr  = "bits";
00447             break;
00448         case moab::MB_TYPE_OPAQUE:
00449             typesize = 1;
00450             typestr  = "bytes";
00451             break;
00452         default:
00453             typesize = 1;
00454             typestr  = "???";
00455             break;
00456     }
00457 
00458     int size;
00459     rval = mb.tag_get_length( tag, size );
00460     if( moab::MB_VARIABLE_DATA_LENGTH == rval )
00461         s << "VAR " << typestr;
00462     else if( moab::MB_SUCCESS == rval )
00463         s << size / typesize << " " << typestr;
00464     // else do nothing
00465 
00466     return s.str();
00467 }
00468 
00469 std::string tag_storage_string( moab::Interface& mb, moab::Tag tag )
00470 {
00471     moab::ErrorCode rval;
00472     moab::TagType type;
00473     rval = mb.tag_get_type( tag, type );
00474     if( moab::MB_SUCCESS != rval ) return std::string();
00475 
00476     switch( type )
00477     {
00478         case moab::MB_TAG_DENSE:
00479             return "dense";
00480         case moab::MB_TAG_SPARSE:
00481             return "sparse";
00482         case moab::MB_TAG_BIT:
00483             return "bit";
00484         default:
00485             return "(none)";
00486     }
00487 }
00488 
00489 std::string center( const char* str, size_t width )
00490 {
00491     std::string text( str );
00492     if( text.size() >= width ) return text;
00493 
00494     width -= text.size();
00495     if( 1u == width )
00496     {
00497         text += " ";
00498         return text;
00499     }
00500 
00501     std::ostringstream s;
00502     s << std::setw( width / 2 ) << ' ' << text << std::setw( width / 2 + width % 2 ) << ' ';
00503     return s.str();
00504 }
00505 
00506 void do_test_mode()
00507 {
00508     const char prefix[] = "****************";
00509     moab::Core mbcore;
00510     moab::Interface& mb = mbcore;
00511     moab::ErrorCode rval;
00512     moab::Range handles;
00513     moab::EntityHandle h;
00514     moab::Range::iterator jt, it;
00515     const unsigned N = 1000;
00516 
00517     // creating some vertices
00518     double coords[3] = { 1, 2, 3 };
00519     for( unsigned i = 0; i < N; ++i )
00520         mb.create_vertex( coords, h );
00521     std::cout << std::endl << prefix << "Created " << N << " vertices" << std::endl;
00522     print_memory_stats( mb, true, false, true, true );
00523 
00524     for( unsigned i = 0; i < N; ++i )
00525         mb.create_vertex( coords, h );
00526     std::cout << std::endl << prefix << "Created another " << N << " vertices" << std::endl;
00527     print_memory_stats( mb, true, false, true, true );
00528 
00529     for( int i = 0; i < 100; ++i )
00530     {
00531         for( unsigned j = 0; j < N; ++j )
00532             mb.create_vertex( coords, h );
00533     }
00534     std::cout << std::endl << prefix << "Created another " << 100 * N << " vertices" << std::endl;
00535     print_memory_stats( mb, true, false, true, true );
00536 
00537     // create some elements
00538     handles.clear();
00539     mb.get_entities_by_type( 0, moab::MBVERTEX, handles );
00540     it = handles.begin();
00541     for( unsigned i = 0; i < N - 2; ++i, ++it )
00542     {
00543         jt = it;
00544         moab::EntityHandle conn[3];
00545         conn[0] = *jt;
00546         ++jt;
00547         conn[1] = *jt;
00548         ++jt;
00549         conn[2] = *jt;
00550         ++jt;
00551         mb.create_element( moab::MBTRI, conn, 3, h );
00552     }
00553     std::cout << std::endl << prefix << "Created " << N - 2 << " triangles" << std::endl;
00554     print_memory_stats( mb, true, false, true, true );
00555 
00556     it = handles.begin();
00557     for( unsigned i = 0; i < N - 3; ++i, ++it )
00558     {
00559         jt = it;
00560         moab::EntityHandle conn[4];
00561         conn[0] = *jt;
00562         ++jt;
00563         conn[1] = *jt;
00564         ++jt;
00565         conn[2] = *jt;
00566         ++jt;
00567         conn[3] = *jt;
00568         ++jt;
00569         mb.create_element( moab::MBQUAD, conn, 4, h );
00570     }
00571     std::cout << std::endl << prefix << "Created " << N - 3 << " quads" << std::endl;
00572     print_memory_stats( mb, true, false, true, true );
00573 
00574     for( int i = 0; i < 100; ++i )
00575     {
00576         it = handles.begin();
00577         for( unsigned j = 0; j < N - 3; ++j, ++it )
00578         {
00579             jt = it;
00580             moab::EntityHandle conn[4];
00581             conn[0] = *jt;
00582             ++jt;
00583             conn[1] = *jt;
00584             ++jt;
00585             conn[2] = *jt;
00586             ++jt;
00587             conn[3] = *jt;
00588             ++jt;
00589             mb.create_element( moab::MBQUAD, conn, 4, h );
00590         }
00591     }
00592     std::cout << std::endl << prefix << "Created another " << 100 * ( N - 3 ) << " quads" << std::endl;
00593     print_memory_stats( mb, true, false, true, true );
00594 
00595     // set global ID
00596     moab::Tag tag;
00597     rval = mb.tag_get_handle( "GLOBAL_ID", 1, moab::MB_TYPE_INTEGER, tag );
00598     if( moab::MB_SUCCESS != rval )
00599     {
00600         std::cerr << "Failed to get GLOBAL_ID tag handle" << std::endl;
00601         return;
00602     }
00603     handles.clear();
00604     mb.get_entities_by_type( 0, moab::MBVERTEX, handles );
00605     int id = 1;
00606     for( it = handles.begin(); it != handles.end(); ++it )
00607     {
00608         mb.tag_set_data( tag, &*it, 1, &id );
00609         ++id;
00610     }
00611     std::cout << std::endl << prefix << "Set global ID tag on " << handles.size() << " vertices" << std::endl;
00612     print_memory_stats( mb, true, true, true, true );
00613 
00614     handles.clear();
00615     mb.get_entities_by_type( 0, moab::MBQUAD, handles );
00616     id = 1;
00617     for( it = handles.begin(); it != handles.end(); ++it )
00618     {
00619         mb.tag_set_data( tag, &*it, 1, &id );
00620         ++id;
00621     }
00622     std::cout << std::endl << prefix << "Set global ID tag on " << handles.size() << " quads" << std::endl;
00623     print_memory_stats( mb, true, true, true, true );
00624 
00625     // create and set a sparse tag
00626     mb.tag_get_handle( "mem_test_tag", 3, moab::MB_TYPE_DOUBLE, tag, moab::MB_TAG_SPARSE | moab::MB_TAG_CREAT );
00627     handles.clear();
00628     mb.get_entities_by_type( 0, moab::MBVERTEX, handles );
00629     for( it = handles.begin(); it != handles.end(); ++it )
00630     {
00631         mb.get_coords( &*it, 1, coords );
00632         mb.tag_set_data( tag, &*it, 1, coords );
00633     }
00634     std::cout << std::endl
00635               << prefix << "Copied vertex coords to sparse tag for " << handles.size() << " vertices" << std::endl;
00636     print_memory_stats( mb, true, true, true, true );
00637 
00638     // create and set bit tag
00639     mb.tag_get_handle( "mem_test_bit", 1, moab::MB_TYPE_BIT, tag, moab::MB_TAG_CREAT );
00640     handles.clear();
00641     mb.get_entities_by_type( 0, moab::MBTRI, handles );
00642     for( it = handles.begin(); it != handles.end(); ++it )
00643     {
00644         char byte = '\001';
00645         mb.tag_set_data( tag, &*it, 1, &byte );
00646     }
00647     std::cout << std::endl << prefix << "Set 1-bit tag for " << handles.size() << " triangles" << std::endl;
00648     print_memory_stats( mb, true, true, true, true );
00649 
00650     // create vertex to element adjacency data
00651     handles.clear();
00652     mb.get_entities_by_type( 0, moab::MBVERTEX, handles );
00653     std::vector< moab::EntityHandle > adj_vec;
00654     mb.get_adjacencies( &*handles.begin(), 1, 2, false, adj_vec );
00655     std::cout << std::endl << prefix << "Created vertex-to-element adjacencies" << std::endl;
00656     print_memory_stats( mb, true, false, true, true );
00657     std::cout << std::endl;
00658 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines