MOAB: Mesh Oriented datABase  (version 5.4.1)
umr_perf.cpp
Go to the documentation of this file.
00001 /*This function profiles the performance of the AHF datastructure */
00002 #include <iostream>
00003 #include <cassert>
00004 #include <ctime>
00005 #include <vector>
00006 #include "moab/Core.hpp"
00007 #include "moab/Range.hpp"
00008 #include "moab/MeshTopoUtil.hpp"
00009 #include "moab/HalfFacetRep.hpp"
00010 #include "moab/NestedRefine.hpp"
00011 #include "../TestUtil.hpp"
00012 #include "moab/CpuTimer.hpp"
00013 
00014 #ifdef MOAB_HAVE_MPI
00015 #include "moab/ParallelComm.hpp"
00016 #include "MBParallelConventions.h"
00017 #include "moab/FileOptions.hpp"
00018 #include "MBTagConventions.hpp"
00019 #include "moab_mpi.h"
00020 #endif
00021 
00022 using namespace moab;
00023 
00024 #ifdef MOAB_HAVE_MPI
00025 std::string read_options;
00026 #endif
00027 
00028 int number_tests_successful = 0;
00029 int number_tests_failed     = 0;
00030 
00031 struct mesh_mem
00032 {
00033 
00034     /* unsigned long long total_storage;
00035      unsigned long long amortized_total_storage;
00036      unsigned long long entity_storage;
00037      unsigned long long amortized_entity_storage;
00038      unsigned long long adjacency_storage;
00039      unsigned long long amortized_adjacency_storage;
00040      unsigned long long tag_storage;
00041      unsigned long long amortized_tag_storage;*/
00042 
00043     // Total storage
00044     unsigned long long total_storage;
00045     unsigned long long total_amortized_storage;
00046 
00047     // Adjacency storage
00048     unsigned long long adj_storage;
00049     unsigned long long amortized_adj_storage;
00050 
00051     // Vertex storage
00052     unsigned long long vertex_storage;
00053     unsigned long long amortized_vertex_storage;
00054 
00055     // Entity storage
00056     unsigned long long entity_storage;
00057     unsigned long long amortized_entity_storage;
00058 };
00059 
00060 enum OUTTYPE
00061 {
00062     TIME = 0,
00063     MEM,
00064     BOTH
00065 };
00066 
00067 void handle_error_code( ErrorCode rv, int& number_failed, int& number_successful )
00068 {
00069     if( rv == MB_SUCCESS )
00070     {
00071 #ifdef MOAB_HAVE_MPI
00072         int rank = 0;
00073         MPI_Comm_rank( MPI_COMM_WORLD, &rank );
00074         if( rank == 0 ) std::cout << "Success";
00075 #else
00076         std::cout << "Success";
00077 #endif
00078         number_successful++;
00079     }
00080     else
00081     {
00082         std::cout << "Failure";
00083         number_failed++;
00084     }
00085 }
00086 
00087 ErrorCode umr_perf_test( Core* mb, int* level_degrees, int num_levels, OUTTYPE output )
00088 {
00089     ErrorCode error;
00090     Interface* mbImpl = mb;
00091 
00092     mesh_mem* umem = new mesh_mem[num_levels + 2];
00093 
00094     CpuTimer* mt = new CpuTimer;
00095     double time_start, time_avg, time_total;
00096 
00097     // Create ranges of entities in the initial mesh
00098     Range inverts, inedges, infaces, incells;
00099     error = mbImpl->get_entities_by_dimension( 0, 0, inverts );
00100     error = mbImpl->get_entities_by_dimension( 0, 1, inedges );
00101     error = mbImpl->get_entities_by_dimension( 0, 2, infaces );
00102     error = mbImpl->get_entities_by_dimension( 0, 3, incells );
00103 
00104     Range init_ents;
00105     int dim = 0;
00106     if( inedges.size() )
00107     {
00108         dim       = 1;
00109         init_ents = inedges;
00110     }
00111     else if( infaces.size() )
00112     {
00113         dim       = 2;
00114         init_ents = infaces;
00115     }
00116     else if( incells.size() )
00117     {
00118         dim       = 3;
00119         init_ents = incells;
00120     }
00121 
00122     std::cout << std::endl;
00123     std::cout << "Initial Mesh Size: "
00124               << "NV = " << inverts.size() << ", NE = " << init_ents.size() << std::endl;
00125 
00126     if( output == MEM || output == BOTH )
00127     {
00128         // Storage Costs before mesh hierarchy generation
00129         /*     std::cout<<std::endl;
00130              unsigned long long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
00131              sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
00132              mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0,
00133            &sTS, &sATS);
00134 
00135              umem[0].total_storage = sTotS;
00136              umem[0].amortized_total_storage = sTAS;
00137              umem[0].entity_storage = sES;
00138              umem[0].amortized_entity_storage = sAES;
00139              umem[0].adjacency_storage = sAS;
00140              umem[0].amortized_adjacency_storage = sAAS;
00141              umem[0].tag_storage = sTS;
00142              umem[0].amortized_tag_storage = sATS;*/
00143 
00144         unsigned long long vTotS, vTAS, vES, vAES, vAS, vAAS, vTS, vATS;
00145         vTotS = vTAS = vES = vAES = vAS = vAAS = vTS = vATS = 0;
00146         mbImpl->estimated_memory_use( inverts, &vTotS, &vTAS, &vES, &vAES, &vAS, &vAAS, NULL, 0, &vTS, &vATS );
00147 
00148         unsigned long long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
00149         eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
00150         mbImpl->estimated_memory_use( init_ents, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS );
00151 
00152         umem[0].total_storage  = vTotS + eTotS;
00153         umem[0].vertex_storage = vES;
00154         umem[0].entity_storage = eES;
00155         //  umem[0].tag_storage = vTS+eTS;
00156 
00157         std::cout << "MEMORY STORAGE:: Initial Mesh" << std::endl;
00158         std::cout << std::endl;
00159         std::cout << "Total storage = " << umem[0].total_storage << std::endl;
00160         std::cout << "Vertex storage = " << umem[0].vertex_storage << std::endl;
00161         std::cout << "Entity storage = " << umem[0].entity_storage << std::endl;
00162         //  std::cout<<"Tag storage = "<< umem[0].tag_storage<<std::endl;
00163 
00164         /*    std::cout<<"Total storage = "<<umem[0].total_storage<<std::endl;
00165             std::cout<<"Total amortized storage = "<< umem[0].amortized_total_storage<<std::endl;
00166             std::cout<<"Entity storage = "<<umem[0].entity_storage<<std::endl;
00167             std::cout<<"Amortized entity storage = "<<umem[0].amortized_entity_storage<<std::endl;
00168             std::cout<<"Adjacency storage = "<< umem[0].adjacency_storage <<std::endl;
00169             std::cout<<"Amortized adjacency storage = "<<umem[0].amortized_adjacency_storage
00170            <<std::endl; std::cout<<"Tag storage = "<< umem[0].tag_storage<<std::endl;
00171             std::cout<<"Amortized tag storage = "<<umem[0].amortized_tag_storage <<std::endl;*/
00172         std::cout << std::endl;
00173     }
00174 
00175     // Create an hm object and generate the hierarchy
00176     std::cout << "Creating a hm object" << std::endl;
00177     NestedRefine uref( mb );
00178     std::vector< EntityHandle > set;
00179 
00180     std::cout << "Starting hierarchy generation" << std::endl;
00181     time_start = mt->time_elapsed();
00182     error      = uref.generate_mesh_hierarchy( num_levels, level_degrees, set );CHECK_ERR( error );
00183 
00184     time_total = mt->time_elapsed() - time_start;
00185     std::cout << "Finished hierarchy generation" << std::endl;
00186 
00187     if( output == TIME || output == BOTH )
00188     {
00189         std::cout << "Total time in secs:: generate mesh hierarchy:: L = " << num_levels << " :: " << time_total
00190                   << std::endl;
00191         std::cout << std::endl;
00192     }
00193 
00194     // Loop over each mesh level and check its topological properties
00195     for( int l = 0; l < num_levels; l++ )
00196     {
00197         // Get the current mesh level using its meshset
00198         Range verts, ents;
00199         error = mbImpl->get_entities_by_type( set[l + 1], MBVERTEX, verts );CHECK_ERR( error );
00200         error = mbImpl->get_entities_by_dimension( set[l + 1], dim, ents );CHECK_ERR( error );
00201 
00202         std::cout << "Mesh size for level " << l + 1 << " :: deg = " << level_degrees[l] << " :: NV = " << verts.size()
00203                   << ", NE = " << ents.size() << std::endl;
00204 
00205         if( output == MEM || output == BOTH )
00206         {
00207             // Storage Costs
00208             std::cout << std::endl;
00209             unsigned long long vTotS, vTAS, vES, vAES, vAS, vAAS, vTS, vATS;
00210             vTotS = vTAS = vES = vAES = vAS = vAAS = vTS = vATS = 0;
00211             mbImpl->estimated_memory_use( verts, &vTotS, &vTAS, &vES, &vAES, &vAS, &vAAS, NULL, 0, &vTS, &vATS );
00212             unsigned long long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
00213             eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
00214             mbImpl->estimated_memory_use( ents, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS );
00215 
00216             umem[l + 1].total_storage  = vTotS + eTotS;
00217             umem[l + 1].vertex_storage = vES;
00218             umem[l + 1].entity_storage = eES;
00219             //   umem[l+1].tag_storage = vTS+eTS;
00220 
00221             /* umem[l+1].total_storage = vTotS+eTotS;
00222              umem[l+1].amortized_total_storage = vTAS+eTAS;
00223              umem[l+1].entity_storage = vES+eES;
00224              umem[l+1].amortized_entity_storage = vAES+eAES;
00225              umem[l+1].adjacency_storage = vAS+eAS;
00226              umem[l+1].amortized_adjacency_storage = vAAS+eAAS;
00227              umem[l+1].tag_storage = vTS+eTS;
00228              umem[l+1].amortized_tag_storage = vATS+eATS;*/
00229 
00230             std::cout << "MEMORY STORAGE:: Mesh level " << l + 1 << std::endl;
00231             std::cout << std::endl;
00232             std::cout << "Total storage = " << umem[l + 1].total_storage << std::endl;
00233             std::cout << "Vertex storage = " << umem[l + 1].vertex_storage << std::endl;
00234             std::cout << "Entity storage = " << umem[l + 1].entity_storage << std::endl;
00235             //   std::cout<<"Tag storage = "<< umem[l+1].tag_storage<<std::endl;
00236 
00237             /*  std::cout<<"Total storage = "<<umem[l+1].total_storage<<std::endl;
00238               std::cout<<"Total amortized storage = "<<
00239               umem[l+1].amortized_total_storage<<std::endl; std::cout<<"Entity storage =
00240               "<<umem[l+1].entity_storage<<std::endl; std::cout<<"Amortized entity storage =
00241               "<<umem[l+1].amortized_entity_storage<<std::endl; std::cout<<"Adjacency storage = "<<
00242               umem[l+1].adjacency_storage <<std::endl; std::cout<<"Amortized adjacency storage =
00243               "<<umem[l+1].amortized_adjacency_storage <<std::endl; std::cout<<"Tag storage = "<<
00244               umem[l+1].tag_storage<<std::endl; std::cout<<"Amortized tag storage =
00245               "<<umem[l+1].amortized_tag_storage <<std::endl;*/
00246             std::cout << std::endl;
00247         }
00248 
00249         if( output == BOTH )
00250         {
00251             // Loop over all vertices and get their coordinates
00252             time_start = mt->time_elapsed();
00253             for( Range::iterator i = verts.begin(); i != verts.end(); ++i )
00254             {
00255                 double coords[3];
00256                 EntityHandle vid = *i;
00257                 error            = uref.get_coordinates( &vid, 1, (int)l, &coords[0] );CHECK_ERR( error );
00258             }
00259             time_total = mt->time_elapsed() - time_start;
00260             time_avg   = time_total / (double)verts.size();
00261 
00262             std::cout << "Class NR :: OPERATION:: get_coordinates"
00263                       << " :: Time_total = " << time_total << " :: Time_avg = " << time_avg << std::endl;
00264 
00265             time_start = mt->time_elapsed();
00266             for( Range::iterator i = verts.begin(); i != verts.end(); ++i )
00267             {
00268                 double coords[3];
00269                 EntityHandle vid = *i;
00270                 error            = mbImpl->get_coords( &vid, 1, &coords[0] );CHECK_ERR( error );
00271             }
00272             time_total = mt->time_elapsed() - time_start;
00273             time_avg   = time_total / (double)verts.size();
00274 
00275             std::cout << "Class Core :: OPERATION:: get_coordinates"
00276                       << " :: Time_total = " << time_total << " :: Time_avg = " << time_avg << std::endl;
00277 
00278             // Loop over all entities and get their connectivity
00279             time_start = mt->time_elapsed();
00280             for( Range::iterator i = ents.begin(); i != ents.end(); ++i )
00281             {
00282                 std::vector< EntityHandle > conn;
00283                 error = uref.get_connectivity( *i, l, conn );CHECK_ERR( error );
00284             }
00285             time_total = mt->time_elapsed() - time_start;
00286             time_avg   = time_total / (double)ents.size();
00287             std::cout << std::endl;
00288             std::cout << "Class NR :: OPERATION:: get_connectivity"
00289                       << " :: Time_total = " << time_total << " :: Time_avg = " << time_avg << std::endl;
00290 
00291             time_start = mt->time_elapsed();
00292             for( Range::iterator i = ents.begin(); i != ents.end(); ++i )
00293             {
00294                 std::vector< EntityHandle > conn;
00295                 error = mbImpl->get_connectivity( &*i, 1, conn );CHECK_ERR( error );
00296             }
00297             time_total = mt->time_elapsed() - time_start;
00298             time_avg   = time_total / (double)ents.size();
00299 
00300             std::cout << "Class Core :: OPERATION:: get_connectivity"
00301                       << " :: Time_total = " << time_total << " :: Time_avg = " << time_avg << std::endl;
00302             std::cout << std::endl;
00303         }
00304     }
00305 
00306     /* if (output == MEM || output == BOTH){
00307 
00308          unsigned long long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
00309          sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
00310          mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0,
00311        &sTS, &sATS);
00312 
00313          umem[num_levels+1].total_storage = sTotS;
00314          umem[num_levels+1].amortized_total_storage = sTAS;
00315          umem[num_levels+1].entity_storage = sES;
00316          umem[num_levels+1].amortized_entity_storage = sAES;
00317          umem[num_levels+1].adjacency_storage = sAS;
00318          umem[num_levels+1].amortized_adjacency_storage = sAAS;
00319          umem[num_levels+1].tag_storage = sTS;
00320          umem[num_levels+1].amortized_tag_storage = sATS;
00321 
00322          std::cout<<"MEMORY STORAGE:: WHOLE MESH HIERARCHY"<<std::endl;
00323          std::cout<<std::endl;
00324          std::cout<<"Total storage = "<<umem[num_levels+1].total_storage<<std::endl;
00325          std::cout<<"Total amortized storage = "<<
00326        umem[num_levels+1].amortized_total_storage<<std::endl; std::cout<<"Entity storage =
00327        "<<umem[num_levels+1].entity_storage<<std::endl; std::cout<<"Amortized entity storage =
00328        "<<umem[num_levels+1].amortized_entity_storage<<std::endl; std::cout<<"Adjacency storage =
00329        "<< umem[num_levels+1].adjacency_storage <<std::endl; std::cout<<"Amortized adjacency storage
00330        = "<<umem[num_levels+1].amortized_adjacency_storage <<std::endl; std::cout<<"Tag storage =
00331        "<< umem[num_levels+1].tag_storage<<std::endl; std::cout<<"Amortized tag storage =
00332        "<<umem[num_levels+1].amortized_tag_storage <<std::endl; std::cout<<std::endl;
00333        }*/
00334 
00335     return MB_SUCCESS;
00336 }
00337 
00338 ErrorCode create_simple_mesh( Core* mb, EntityType type )
00339 {
00340     ErrorCode error;
00341     Interface* mbImpl = mb;
00342     if( type == MBEDGE )
00343     {
00344         const double coords[] = { 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0,
00345                                   4, 1, 0, 3, 1, 0, 2, 1, 0, 1, 1, 0, 0, 1, 0 };
00346         const size_t num_vtx  = sizeof( coords ) / sizeof( double ) / 3;
00347 
00348         const int conn[]       = { 1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0 };
00349         const size_t num_elems = sizeof( conn ) / sizeof( int ) / 2;
00350 
00351         EntityHandle verts[num_vtx], edges[num_elems];
00352         for( size_t i = 0; i < num_vtx; ++i )
00353         {
00354             error = mbImpl->create_vertex( coords + 3 * i, verts[i] );
00355             if( error != MB_SUCCESS ) return error;
00356         }
00357 
00358         for( size_t i = 0; i < num_elems; ++i )
00359         {
00360             EntityHandle c[2];
00361             c[0] = verts[conn[2 * i]];
00362             c[1] = verts[conn[2 * i + 1]];
00363 
00364             error = mbImpl->create_element( MBEDGE, c, 2, edges[i] );
00365             if( error != MB_SUCCESS ) return error;
00366         }
00367     }
00368     else if( type == MBTRI )
00369     {
00370         const double coords[] = { 0, 0,    0, 1, 0,    0,  2, 0,   0,  2.5, 1,   0,  1.5, 1,   0,  0.5, 1,
00371                                   0, -0.5, 1, 0, -0.5, -1, 0, 0.5, -1, 0,   1.5, -1, 0,   2.5, -1, 0 };
00372 
00373         const size_t num_vtx = sizeof( coords ) / sizeof( double ) / 3;
00374 
00375         const int conn[] = { 0, 5, 6, 0, 1, 5, 1, 4, 5, 1, 2, 4, 2, 3,  4,
00376                              7, 8, 0, 8, 1, 0, 8, 9, 1, 9, 2, 1, 9, 10, 2 };
00377 
00378         const size_t num_elems = sizeof( conn ) / sizeof( int ) / 3;
00379 
00380         EntityHandle verts[num_vtx], faces[num_elems];
00381         for( size_t i = 0; i < num_vtx; ++i )
00382         {
00383             error = mbImpl->create_vertex( coords + 3 * i, verts[i] );
00384             if( error != MB_SUCCESS ) return error;
00385         }
00386 
00387         for( size_t i = 0; i < num_elems; ++i )
00388         {
00389             EntityHandle c[3];
00390             for( int j = 0; j < 3; j++ )
00391                 c[j] = verts[conn[3 * i + j]];
00392 
00393             error = mbImpl->create_element( MBTRI, c, 3, faces[i] );
00394             if( error != MB_SUCCESS ) return error;
00395         }
00396     }
00397     else if( type == MBQUAD )
00398     {
00399         const double coords[] = { 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 0, 1, 0, 1, 1, 0, 2, 1, 0,
00400                                   3, 1, 0, 4, 1, 0, 5, 1, 0, 0, 2, 0, 1, 2, 0, 2, 2, 0, 3, 2, 0, 4, 2, 0, 5, 2, 0 };
00401 
00402         const size_t num_vtx = sizeof( coords ) / sizeof( double ) / 3;
00403 
00404         const int conn[] = { 0, 1, 7,  6,  1, 2, 8,  7,  2, 3, 9,  8,  3, 4,  10, 9,  4,  5,  11, 10,
00405                              6, 7, 13, 12, 7, 8, 14, 13, 8, 9, 15, 14, 9, 10, 16, 15, 10, 11, 17, 16 };
00406 
00407         const size_t num_elems = sizeof( conn ) / sizeof( int ) / 4;
00408 
00409         EntityHandle verts[num_vtx], faces[num_elems];
00410         for( size_t i = 0; i < num_vtx; ++i )
00411         {
00412             error = mbImpl->create_vertex( coords + 3 * i, verts[i] );
00413             if( error != MB_SUCCESS ) return error;
00414         }
00415 
00416         for( size_t i = 0; i < num_elems; ++i )
00417         {
00418             EntityHandle c[4];
00419             for( int j = 0; j < 4; j++ )
00420                 c[j] = verts[conn[4 * i + j]];
00421 
00422             error = mbImpl->create_element( MBQUAD, c, 4, faces[i] );
00423             if( error != MB_SUCCESS ) return error;
00424         }
00425     }
00426     else if( type == MBTET )
00427     {
00428         const double coords[] = { 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0, 0, 0, -1, 0, 0, 0, 1 };
00429 
00430         const size_t num_vtx = sizeof( coords ) / sizeof( double ) / 3;
00431 
00432         const int conn[] = { 0, 1, 2, 5, 3, 0, 2, 5, 4, 1, 0, 5, 4, 0, 3, 5 };
00433 
00434         const size_t num_elems = sizeof( conn ) / sizeof( int ) / 4;
00435 
00436         EntityHandle verts[num_vtx], cells[num_elems];
00437         for( size_t i = 0; i < num_vtx; ++i )
00438         {
00439             error = mbImpl->create_vertex( coords + 3 * i, verts[i] );
00440             if( error != MB_SUCCESS ) return error;
00441         }
00442 
00443         for( size_t i = 0; i < num_elems; ++i )
00444         {
00445             EntityHandle c[4];
00446             for( int j = 0; j < 4; j++ )
00447                 c[j] = verts[conn[4 * i + j]];
00448 
00449             error = mbImpl->create_element( MBTET, c, 4, cells[i] );
00450             if( error != MB_SUCCESS ) return error;
00451         }
00452     }
00453     else if( type == MBHEX )
00454     {
00455         const double coords[] = { 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 1, 0, 1, 1, 0, 2, 1, 0, 0, 2, 0, 1, 2, 0, 2, 2, 0,
00456                                   0, 0, 1, 1, 0, 1, 2, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 1, 0, 2, 1, 1, 2, 1, 2, 2, 1 };
00457         const size_t num_vtx  = sizeof( coords ) / sizeof( double ) / 3;
00458 
00459         const int conn[]       = { 0, 1, 4, 3, 9,  10, 13, 12, 1, 2, 5, 4, 10, 11, 14, 13,
00460                              3, 4, 7, 6, 12, 13, 16, 15, 4, 5, 8, 7, 13, 14, 17, 16 };
00461         const size_t num_elems = sizeof( conn ) / sizeof( int ) / 8;
00462 
00463         EntityHandle verts[num_vtx], cells[num_elems];
00464         for( size_t i = 0; i < num_vtx; ++i )
00465         {
00466             error = mbImpl->create_vertex( coords + 3 * i, verts[i] );
00467             if( error != MB_SUCCESS ) return error;
00468         }
00469 
00470         for( size_t i = 0; i < num_elems; ++i )
00471         {
00472             EntityHandle c[8];
00473             for( int j = 0; j < 8; j++ )
00474                 c[j] = verts[conn[8 * i + j]];
00475 
00476             error = mbImpl->create_element( MBHEX, c, 8, cells[i] );
00477             if( error != MB_SUCCESS ) return error;
00478         }
00479     }
00480     return MB_SUCCESS;
00481 }
00482 
00483 ErrorCode test_mesh( EntityType type, int* level_degrees, int num_level )
00484 {
00485     ErrorCode error;
00486     Core mb;
00487 
00488     error = create_simple_mesh( &mb, type );
00489     if( error != MB_SUCCESS ) return error;
00490 
00491     OUTTYPE output = BOTH;
00492     error          = umr_perf_test( &mb, level_degrees, num_level, output );
00493     if( error != MB_SUCCESS ) return error;
00494 
00495     return MB_SUCCESS;
00496 }
00497 
00498 ErrorCode test_1D()
00499 {
00500     ErrorCode error;
00501     std::cout << std::endl;
00502     std::cout << "EntityType = MBEDGE" << std::endl;
00503 
00504     std::cout << "Deg = 2" << std::endl;
00505     int deg[7] = { 5, 5, 2, 2, 2, 2, 2 };
00506     int len    = sizeof( deg ) / sizeof( int );
00507     error      = test_mesh( MBEDGE, deg, len );
00508     if( error != MB_SUCCESS ) return error;
00509 
00510     std::cout << std::endl;
00511     std::cout << "Deg = 3" << std::endl;
00512     deg[4] = 3;
00513     deg[5] = 3;
00514     deg[6] = 3;
00515     error  = test_mesh( MBEDGE, deg, len );
00516     if( error != MB_SUCCESS ) return error;
00517 
00518     std::cout << std::endl;
00519     std::cout << "Deg = 5" << std::endl;
00520     deg[4] = 5;
00521     deg[5] = 5;
00522     deg[6] = 5;
00523     error  = test_mesh( MBEDGE, deg, len );
00524     if( error != MB_SUCCESS ) return error;
00525 
00526     return MB_SUCCESS;
00527 }
00528 
00529 ErrorCode test_2D()
00530 {
00531     ErrorCode error;
00532     EntityType type = MBTRI;
00533     std::cout << std::endl;
00534     std::cout << "EntityType = MBTRI" << std::endl;
00535 
00536     std::cout << "Deg = 2" << std::endl;
00537     int deg[5] = { 5, 2, 2, 2, 2 };
00538     int len    = sizeof( deg ) / sizeof( int );
00539     error      = test_mesh( type, deg, len );
00540     if( error != MB_SUCCESS ) return error;
00541 
00542     std::cout << std::endl;
00543     std::cout << "Deg = 3" << std::endl;
00544     deg[2] = 3;
00545     deg[3] = 3;
00546     deg[4] = 3;
00547     error  = test_mesh( type, deg, len );
00548     if( error != MB_SUCCESS ) return error;
00549 
00550     std::cout << std::endl;
00551     std::cout << "Deg = 5" << std::endl;
00552     deg[2] = 5;
00553     deg[3] = 5;
00554     deg[4] = 5;
00555     error  = test_mesh( type, deg, len );
00556     if( error != MB_SUCCESS ) return error;
00557 
00558     type = MBQUAD;
00559     std::cout << std::endl;
00560     std::cout << "EntityType = MBQUAD" << std::endl;
00561 
00562     std::cout << "Deg = 2" << std::endl;
00563     deg[2] = 2;
00564     deg[3] = 2;
00565     deg[4] = 2;
00566     error  = test_mesh( type, deg, len );
00567     if( error != MB_SUCCESS ) return error;
00568 
00569     std::cout << std::endl;
00570     std::cout << "Deg = 3" << std::endl;
00571     deg[2] = 3;
00572     deg[3] = 3;
00573     deg[4] = 3;
00574     error  = test_mesh( type, deg, len );
00575     if( error != MB_SUCCESS ) return error;
00576 
00577     std::cout << std::endl;
00578     std::cout << "Deg = 5" << std::endl;
00579     deg[2] = 5;
00580     deg[3] = 5;
00581     deg[4] = 5;
00582     error  = test_mesh( type, deg, len );
00583     if( error != MB_SUCCESS ) return error;
00584 
00585     return MB_SUCCESS;
00586 }
00587 
00588 ErrorCode test_3D()
00589 {
00590     ErrorCode error;
00591     EntityType type = MBTET;
00592     std::cout << std::endl;
00593     std::cout << "EntityType = MBTET" << std::endl;
00594 
00595     std::cout << "Deg = 2" << std::endl;
00596     int deg[6] = { 2, 2, 2, 2, 2, 2 };
00597     int len    = sizeof( deg ) / sizeof( int );
00598     error      = test_mesh( type, deg, len );
00599     if( error != MB_SUCCESS ) return error;
00600 
00601     std::cout << std::endl;
00602     std::cout << "Deg = 3" << std::endl;
00603     deg[3] = 3;
00604     deg[4] = 3;
00605     deg[5] = 3;
00606     error  = test_mesh( type, deg, len );
00607     if( error != MB_SUCCESS ) return error;
00608 
00609     type = MBHEX;
00610     std::cout << std::endl;
00611     std::cout << "EntityType = MBHEX" << std::endl;
00612 
00613     std::cout << "Deg = 2" << std::endl;
00614     deg[3] = 2;
00615     deg[4] = 2;
00616     deg[5] = 2;
00617     error  = test_mesh( type, deg, len );
00618     if( error != MB_SUCCESS ) return error;
00619 
00620     std::cout << std::endl;
00621     std::cout << "Deg = 3" << std::endl;
00622     deg[3] = 3;
00623     deg[4] = 3;
00624     deg[5] = 3;
00625     error  = test_mesh( type, deg, len );
00626     if( error != MB_SUCCESS ) return error;
00627 
00628     return MB_SUCCESS;
00629 }
00630 
00631 ErrorCode perf_inmesh( const char* filename, int* level_degrees, int num_levels, OUTTYPE output )
00632 {
00633     ErrorCode error;
00634     Core mb;
00635     Interface* mbImpl = &mb;
00636 
00637 #ifdef MOAB_HAVE_MPI
00638     int procs = 1;
00639     MPI_Comm_size( MPI_COMM_WORLD, &procs );
00640 
00641     if( procs > 1 )
00642     {
00643         read_options = "PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION;PARALLEL_RESOLVE_SHARED_ENTS;";
00644 
00645         error = mbImpl->load_file( filename, 0, read_options.c_str() );CHECK_ERR( error );
00646     }
00647     else if( procs == 1 )
00648     {
00649 #endif
00650         error = mbImpl->load_file( filename );CHECK_ERR( error );
00651 #ifdef MOAB_HAVE_MPI
00652     }
00653 #endif
00654     //  OUTTYPE output = MEM;
00655     error = umr_perf_test( &mb, level_degrees, num_levels, output );
00656     if( error != MB_SUCCESS ) return error;
00657 
00658     return MB_SUCCESS;
00659 }
00660 
00661 int main( int argc, char* argv[] )
00662 {
00663 
00664 #ifdef MOAB_HAVE_MPI
00665     MPI_Init( &argc, &argv );
00666 
00667     int nprocs, rank;
00668     MPI_Comm_size( MPI_COMM_WORLD, &nprocs );
00669     MPI_Comm_rank( MPI_COMM_WORLD, &rank );
00670 #endif
00671 
00672 #ifdef MOAB_HAVE_MPI
00673     if( rank == 0 ) std::cout << " para_umr_perf: ";
00674 #else
00675     std::cout << "umr_perf:";
00676 #endif
00677 
00678     if( argc == 1 )
00679     {
00680         ErrorCode result;
00681 
00682         result = test_1D();
00683         handle_error_code( result, number_tests_failed, number_tests_successful );
00684         std::cout << "\n";
00685 
00686         result = test_2D();
00687         handle_error_code( result, number_tests_failed, number_tests_successful );
00688         std::cout << "\n";
00689 
00690         result = test_3D();
00691         handle_error_code( result, number_tests_failed, number_tests_successful );
00692         std::cout << "\n";
00693     }
00694 
00695     else if( argc == 2 )
00696     {
00697         const char* filename = argv[1];
00698         ErrorCode result;
00699 
00700         OUTTYPE output = MEM;
00701 
00702         if( output == MEM )
00703         {
00704             int deg[3] = { 2, 2, 2 };
00705             int len    = sizeof( deg ) / sizeof( int );
00706             result     = perf_inmesh( filename, deg, len, output );
00707             handle_error_code( result, number_tests_failed, number_tests_successful );
00708             std::cout << "\n";
00709 
00710             deg[0] = 3;
00711             deg[1] = 3;
00712             deg[2] = 3;
00713             result = perf_inmesh( filename, deg, len, output );
00714             handle_error_code( result, number_tests_failed, number_tests_successful );
00715             std::cout << "\n";
00716 
00717             /*  deg[0] = 5; deg[1] = 5; deg[2] = 5;
00718               result = perf_inmesh(filename, deg, len, output);
00719               handle_error_code(result, number_tests_failed, number_tests_successful);
00720               std::cout<<"\n";*/
00721         }
00722         else if( output == TIME )
00723         {
00724             for( int L = 0; L < 3; L++ )
00725             {
00726                 int* level_degrees = new int[L + 1];
00727                 for( int i = 0; i < L + 1; i++ )
00728                 {
00729                     level_degrees[i] = 3;
00730                 }
00731 
00732                 result = perf_inmesh( filename, level_degrees, L + 1, output );
00733                 handle_error_code( result, number_tests_failed, number_tests_successful );
00734                 std::cout << "\n";
00735 
00736                 delete[] level_degrees;
00737             }
00738         }
00739     }
00740     else
00741     {
00742         std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
00743         return 1;
00744     }
00745 
00746 #ifdef MOAB_HAVE_MPI
00747     MPI_Finalize();
00748 #endif
00749 
00750     return number_tests_failed;
00751 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines