MOAB: Mesh Oriented datABase
(version 5.4.1)
|
00001 #include "moab/Core.hpp" 00002 #include "moab/Range.hpp" 00003 #include "TestUtil.hpp" 00004 #include <iostream> 00005 #include <cassert> 00006 #include <ctime> 00007 00008 using namespace moab; 00009 00010 static const std::string default_input_file = TestDir + "unittest/64bricks_512hex.h5m"; 00011 00012 int main() 00013 { 00014 ErrorCode rval; 00015 Core moab; 00016 Interface& mb = moab; 00017 00018 // load test file 00019 rval = mb.load_file( default_input_file.c_str() ); 00020 if( MB_SUCCESS != rval ) 00021 { 00022 std::cerr << default_input_file << ": failed to load file." << std::endl; 00023 return 1; 00024 } 00025 00026 // get all region elements 00027 Range vols; 00028 rval = mb.get_entities_by_dimension( 0, 3, vols ); 00029 if( MB_SUCCESS != rval ) return 2; 00030 if( vols.empty() ) return 1; 00031 00032 // create internal face elements 00033 Range faces; 00034 rval = mb.get_adjacencies( vols, 2, true, faces, Interface::UNION ); 00035 if( MB_SUCCESS != rval ) return 2; 00036 assert( faces.size() > vols.size() ); 00037 00038 // time query of all adjacent volumes 00039 std::vector< EntityHandle > adj; 00040 clock_t t_0 = clock(); 00041 for( Range::iterator i = faces.begin(); i != faces.end(); ++i ) 00042 { 00043 adj.clear(); 00044 rval = mb.get_adjacencies( &*i, 1, 3, false, adj ); 00045 if( MB_SUCCESS != rval ) return 2; 00046 assert( adj.size() == 1 || adj.size() == 2 ); 00047 } 00048 clock_t t_up = clock() - t_0; 00049 std::cout << "Querying of volumes for " << faces.size() << " faces: " << t_up / (double)CLOCKS_PER_SEC << " seconds" 00050 << std::endl; 00051 00052 // time downward adjacency query from volumes to faces 00053 t_0 = clock(); 00054 for( Range::iterator i = vols.begin(); i != vols.end(); ++i ) 00055 { 00056 adj.clear(); 00057 rval = mb.get_adjacencies( &*i, 1, 1, false, adj ); 00058 if( MB_SUCCESS != rval ) return 2; 00059 assert( adj.size() > 3 ); 00060 } 00061 clock_t t_down = clock() - t_0; 00062 std::cout << "Querying of faces for " << vols.size() << " volumes: " << t_down / (double)CLOCKS_PER_SEC 00063 << " seconds" << std::endl; 00064 00065 return 0; 00066 }