MOAB: Mesh Oriented datABase  (version 5.2.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 <assert.h>
00004 #include <time.h>
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[] = {
00376             0, 5, 6, 0, 1, 5, 1, 4, 5, 1, 2, 4, 2, 3, 4, 7, 8, 0, 8, 1, 0, 8, 9, 1, 9, 2, 1, 9, 10, 2
00377         };
00378 
00379         const size_t num_elems = sizeof( conn ) / sizeof( int ) / 3;
00380 
00381         EntityHandle verts[num_vtx], faces[num_elems];
00382         for( size_t i = 0; i < num_vtx; ++i )
00383         {
00384             error = mbImpl->create_vertex( coords + 3 * i, verts[i] );
00385             if( error != MB_SUCCESS ) return error;
00386         }
00387 
00388         for( size_t i = 0; i < num_elems; ++i )
00389         {
00390             EntityHandle c[3];
00391             for( int j = 0; j < 3; j++ )
00392                 c[j] = verts[conn[3 * i + j]];
00393 
00394             error = mbImpl->create_element( MBTRI, c, 3, faces[i] );
00395             if( error != MB_SUCCESS ) return error;
00396         }
00397     }
00398     else if( type == MBQUAD )
00399     {
00400         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,
00401                                   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 };
00402 
00403         const size_t num_vtx = sizeof( coords ) / sizeof( double ) / 3;
00404 
00405         const int conn[] = { 0, 1, 7,  6,  1, 2, 8,  7,  2, 3, 9,  8,  3, 4,  10, 9,  4,  5,  11, 10,
00406                              6, 7, 13, 12, 7, 8, 14, 13, 8, 9, 15, 14, 9, 10, 16, 15, 10, 11, 17, 16 };
00407 
00408         const size_t num_elems = sizeof( conn ) / sizeof( int ) / 4;
00409 
00410         EntityHandle verts[num_vtx], faces[num_elems];
00411         for( size_t i = 0; i < num_vtx; ++i )
00412         {
00413             error = mbImpl->create_vertex( coords + 3 * i, verts[i] );
00414             if( error != MB_SUCCESS ) return error;
00415         }
00416 
00417         for( size_t i = 0; i < num_elems; ++i )
00418         {
00419             EntityHandle c[4];
00420             for( int j = 0; j < 4; j++ )
00421                 c[j] = verts[conn[4 * i + j]];
00422 
00423             error = mbImpl->create_element( MBQUAD, c, 4, faces[i] );
00424             if( error != MB_SUCCESS ) return error;
00425         }
00426     }
00427     else if( type == MBTET )
00428     {
00429         const double coords[] = { 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0, 0, 0, -1, 0, 0, 0, 1 };
00430 
00431         const size_t num_vtx = sizeof( coords ) / sizeof( double ) / 3;
00432 
00433         const int conn[] = { 0, 1, 2, 5, 3, 0, 2, 5, 4, 1, 0, 5, 4, 0, 3, 5 };
00434 
00435         const size_t num_elems = sizeof( conn ) / sizeof( int ) / 4;
00436 
00437         EntityHandle verts[num_vtx], cells[num_elems];
00438         for( size_t i = 0; i < num_vtx; ++i )
00439         {
00440             error = mbImpl->create_vertex( coords + 3 * i, verts[i] );
00441             if( error != MB_SUCCESS ) return error;
00442         }
00443 
00444         for( size_t i = 0; i < num_elems; ++i )
00445         {
00446             EntityHandle c[4];
00447             for( int j = 0; j < 4; j++ )
00448                 c[j] = verts[conn[4 * i + j]];
00449 
00450             error = mbImpl->create_element( MBTET, c, 4, cells[i] );
00451             if( error != MB_SUCCESS ) return error;
00452         }
00453     }
00454     else if( type == MBHEX )
00455     {
00456         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,
00457                                   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 };
00458         const size_t num_vtx  = sizeof( coords ) / sizeof( double ) / 3;
00459 
00460         const int conn[]       = { 0, 1, 4, 3, 9,  10, 13, 12, 1, 2, 5, 4, 10, 11, 14, 13,
00461                              3, 4, 7, 6, 12, 13, 16, 15, 4, 5, 8, 7, 13, 14, 17, 16 };
00462         const size_t num_elems = sizeof( conn ) / sizeof( int ) / 8;
00463 
00464         EntityHandle verts[num_vtx], cells[num_elems];
00465         for( size_t i = 0; i < num_vtx; ++i )
00466         {
00467             error = mbImpl->create_vertex( coords + 3 * i, verts[i] );
00468             if( error != MB_SUCCESS ) return error;
00469         }
00470 
00471         for( size_t i = 0; i < num_elems; ++i )
00472         {
00473             EntityHandle c[8];
00474             for( int j = 0; j < 8; j++ )
00475                 c[j] = verts[conn[8 * i + j]];
00476 
00477             error = mbImpl->create_element( MBHEX, c, 8, cells[i] );
00478             if( error != MB_SUCCESS ) return error;
00479         }
00480     }
00481     return MB_SUCCESS;
00482 }
00483 
00484 ErrorCode test_mesh( EntityType type, int* level_degrees, int num_level )
00485 {
00486     ErrorCode error;
00487     Core mb;
00488 
00489     error = create_simple_mesh( &mb, type );
00490     if( error != MB_SUCCESS ) return error;
00491 
00492     OUTTYPE output = BOTH;
00493     error          = umr_perf_test( &mb, level_degrees, num_level, output );
00494     if( error != MB_SUCCESS ) return error;
00495 
00496     return MB_SUCCESS;
00497 }
00498 
00499 ErrorCode test_1D()
00500 {
00501     ErrorCode error;
00502     std::cout << std::endl;
00503     std::cout << "EntityType = MBEDGE" << std::endl;
00504 
00505     std::cout << "Deg = 2" << std::endl;
00506     int deg[7] = { 5, 5, 2, 2, 2, 2, 2 };
00507     int len    = sizeof( deg ) / sizeof( int );
00508     error      = test_mesh( MBEDGE, deg, len );
00509     if( error != MB_SUCCESS ) return error;
00510 
00511     std::cout << std::endl;
00512     std::cout << "Deg = 3" << std::endl;
00513     deg[4] = 3;
00514     deg[5] = 3;
00515     deg[6] = 3;
00516     error  = test_mesh( MBEDGE, deg, len );
00517     if( error != MB_SUCCESS ) return error;
00518 
00519     std::cout << std::endl;
00520     std::cout << "Deg = 5" << std::endl;
00521     deg[4] = 5;
00522     deg[5] = 5;
00523     deg[6] = 5;
00524     error  = test_mesh( MBEDGE, deg, len );
00525     if( error != MB_SUCCESS ) return error;
00526 
00527     return MB_SUCCESS;
00528 }
00529 
00530 ErrorCode test_2D()
00531 {
00532     ErrorCode error;
00533     EntityType type = MBTRI;
00534     std::cout << std::endl;
00535     std::cout << "EntityType = MBTRI" << std::endl;
00536 
00537     std::cout << "Deg = 2" << std::endl;
00538     int deg[5] = { 5, 2, 2, 2, 2 };
00539     int len    = sizeof( deg ) / sizeof( int );
00540     error      = test_mesh( type, deg, len );
00541     if( error != MB_SUCCESS ) return error;
00542 
00543     std::cout << std::endl;
00544     std::cout << "Deg = 3" << std::endl;
00545     deg[2] = 3;
00546     deg[3] = 3;
00547     deg[4] = 3;
00548     error  = test_mesh( type, deg, len );
00549     if( error != MB_SUCCESS ) return error;
00550 
00551     std::cout << std::endl;
00552     std::cout << "Deg = 5" << std::endl;
00553     deg[2] = 5;
00554     deg[3] = 5;
00555     deg[4] = 5;
00556     error  = test_mesh( type, deg, len );
00557     if( error != MB_SUCCESS ) return error;
00558 
00559     type = MBQUAD;
00560     std::cout << std::endl;
00561     std::cout << "EntityType = MBQUAD" << std::endl;
00562 
00563     std::cout << "Deg = 2" << std::endl;
00564     deg[2] = 2;
00565     deg[3] = 2;
00566     deg[4] = 2;
00567     error  = test_mesh( type, deg, len );
00568     if( error != MB_SUCCESS ) return error;
00569 
00570     std::cout << std::endl;
00571     std::cout << "Deg = 3" << std::endl;
00572     deg[2] = 3;
00573     deg[3] = 3;
00574     deg[4] = 3;
00575     error  = test_mesh( type, deg, len );
00576     if( error != MB_SUCCESS ) return error;
00577 
00578     std::cout << std::endl;
00579     std::cout << "Deg = 5" << std::endl;
00580     deg[2] = 5;
00581     deg[3] = 5;
00582     deg[4] = 5;
00583     error  = test_mesh( type, deg, len );
00584     if( error != MB_SUCCESS ) return error;
00585 
00586     return MB_SUCCESS;
00587 }
00588 
00589 ErrorCode test_3D()
00590 {
00591     ErrorCode error;
00592     EntityType type = MBTET;
00593     std::cout << std::endl;
00594     std::cout << "EntityType = MBTET" << std::endl;
00595 
00596     std::cout << "Deg = 2" << std::endl;
00597     int deg[6] = { 2, 2, 2, 2, 2, 2 };
00598     int len    = sizeof( deg ) / sizeof( int );
00599     error      = test_mesh( type, deg, len );
00600     if( error != MB_SUCCESS ) return error;
00601 
00602     std::cout << std::endl;
00603     std::cout << "Deg = 3" << std::endl;
00604     deg[3] = 3;
00605     deg[4] = 3;
00606     deg[5] = 3;
00607     error  = test_mesh( type, deg, len );
00608     if( error != MB_SUCCESS ) return error;
00609 
00610     type = MBHEX;
00611     std::cout << std::endl;
00612     std::cout << "EntityType = MBHEX" << std::endl;
00613 
00614     std::cout << "Deg = 2" << std::endl;
00615     deg[3] = 2;
00616     deg[4] = 2;
00617     deg[5] = 2;
00618     error  = test_mesh( type, deg, len );
00619     if( error != MB_SUCCESS ) return error;
00620 
00621     std::cout << std::endl;
00622     std::cout << "Deg = 3" << std::endl;
00623     deg[3] = 3;
00624     deg[4] = 3;
00625     deg[5] = 3;
00626     error  = test_mesh( type, deg, len );
00627     if( error != MB_SUCCESS ) return error;
00628 
00629     return MB_SUCCESS;
00630 }
00631 
00632 ErrorCode perf_inmesh( const char* filename, int* level_degrees, int num_levels, OUTTYPE output )
00633 {
00634     ErrorCode error;
00635     Core mb;
00636     Interface* mbImpl = &mb;
00637 
00638 #ifdef MOAB_HAVE_MPI
00639     int procs = 1;
00640     MPI_Comm_size( MPI_COMM_WORLD, &procs );
00641 
00642     if( procs > 1 )
00643     {
00644         read_options = "PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION;PARALLEL_RESOLVE_SHARED_ENTS;";
00645 
00646         error = mbImpl->load_file( filename, 0, read_options.c_str() );CHECK_ERR( error );
00647     }
00648     else if( procs == 1 )
00649     {
00650 #endif
00651         error = mbImpl->load_file( filename );CHECK_ERR( error );
00652 #ifdef MOAB_HAVE_MPI
00653     }
00654 #endif
00655     //  OUTTYPE output = MEM;
00656     error = umr_perf_test( &mb, level_degrees, num_levels, output );
00657     if( error != MB_SUCCESS ) return error;
00658 
00659     return MB_SUCCESS;
00660 }
00661 
00662 int main( int argc, char* argv[] )
00663 {
00664 
00665 #ifdef MOAB_HAVE_MPI
00666     MPI_Init( &argc, &argv );
00667 
00668     int nprocs, rank;
00669     MPI_Comm_size( MPI_COMM_WORLD, &nprocs );
00670     MPI_Comm_rank( MPI_COMM_WORLD, &rank );
00671 #endif
00672 
00673 #ifdef MOAB_HAVE_MPI
00674     if( rank == 0 ) std::cout << " para_umr_perf: ";
00675 #else
00676     std::cout << "umr_perf:";
00677 #endif
00678 
00679     if( argc == 1 )
00680     {
00681         ErrorCode result;
00682 
00683         result = test_1D();
00684         handle_error_code( result, number_tests_failed, number_tests_successful );
00685         std::cout << "\n";
00686 
00687         result = test_2D();
00688         handle_error_code( result, number_tests_failed, number_tests_successful );
00689         std::cout << "\n";
00690 
00691         result = test_3D();
00692         handle_error_code( result, number_tests_failed, number_tests_successful );
00693         std::cout << "\n";
00694     }
00695 
00696     else if( argc == 2 )
00697     {
00698         const char* filename = argv[1];
00699         ErrorCode result;
00700 
00701         OUTTYPE output = MEM;
00702 
00703         if( output == MEM )
00704         {
00705             int deg[3] = { 2, 2, 2 };
00706             int len    = sizeof( deg ) / sizeof( int );
00707             result     = perf_inmesh( filename, deg, len, output );
00708             handle_error_code( result, number_tests_failed, number_tests_successful );
00709             std::cout << "\n";
00710 
00711             deg[0] = 3;
00712             deg[1] = 3;
00713             deg[2] = 3;
00714             result = perf_inmesh( filename, deg, len, output );
00715             handle_error_code( result, number_tests_failed, number_tests_successful );
00716             std::cout << "\n";
00717 
00718             /*  deg[0] = 5; deg[1] = 5; deg[2] = 5;
00719               result = perf_inmesh(filename, deg, len, output);
00720               handle_error_code(result, number_tests_failed, number_tests_successful);
00721               std::cout<<"\n";*/
00722         }
00723         else if( output == TIME )
00724         {
00725             for( int L = 0; L < 3; L++ )
00726             {
00727                 int* level_degrees = new int[L + 1];
00728                 for( int i = 0; i < L + 1; i++ )
00729                 {
00730                     level_degrees[i] = 3;
00731                 }
00732 
00733                 result = perf_inmesh( filename, level_degrees, L + 1, output );
00734                 handle_error_code( result, number_tests_failed, number_tests_successful );
00735                 std::cout << "\n";
00736 
00737                 delete[] level_degrees;
00738             }
00739         }
00740     }
00741     else
00742     {
00743         std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
00744         return 1;
00745     }
00746 
00747 #ifdef MOAB_HAVE_MPI
00748     MPI_Finalize();
00749 #endif
00750 
00751     return number_tests_failed;
00752 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines