MOAB: Mesh Oriented datABase  (version 5.5.0)
adj_time.cpp File Reference
#include "moab/Core.hpp"
#include "moab/Range.hpp"
#include "TestUtil.hpp"
#include <iostream>
#include <cassert>
#include <ctime>
+ Include dependency graph for adj_time.cpp:

Go to the source code of this file.

Functions

int main ()
 

Variables

static const std::string default_input_file = TestDir + "unittest/64bricks_512hex.h5m"
 

Function Documentation

◆ main()

int main ( )

Definition at line 12 of file adj_time.cpp.

13 {
14  ErrorCode rval;
15  Core moab;
16  Interface& mb = moab;
17 
18  // load test file
19  rval = mb.load_file( default_input_file.c_str() );
20  if( MB_SUCCESS != rval )
21  {
22  std::cerr << default_input_file << ": failed to load file." << std::endl;
23  return 1;
24  }
25 
26  // get all region elements
27  Range vols;
28  rval = mb.get_entities_by_dimension( 0, 3, vols );
29  if( MB_SUCCESS != rval ) return 2;
30  if( vols.empty() ) return 1;
31 
32  // create internal face elements
33  Range faces;
34  rval = mb.get_adjacencies( vols, 2, true, faces, Interface::UNION );
35  if( MB_SUCCESS != rval ) return 2;
36  assert( faces.size() > vols.size() );
37 
38  // time query of all adjacent volumes
39  std::vector< EntityHandle > adj;
40  clock_t t_0 = clock();
41  for( Range::iterator i = faces.begin(); i != faces.end(); ++i )
42  {
43  adj.clear();
44  rval = mb.get_adjacencies( &*i, 1, 3, false, adj );
45  if( MB_SUCCESS != rval ) return 2;
46  assert( adj.size() == 1 || adj.size() == 2 );
47  }
48  clock_t t_up = clock() - t_0;
49  std::cout << "Querying of volumes for " << faces.size() << " faces: " << t_up / (double)CLOCKS_PER_SEC << " seconds"
50  << std::endl;
51 
52  // time downward adjacency query from volumes to faces
53  t_0 = clock();
54  for( Range::iterator i = vols.begin(); i != vols.end(); ++i )
55  {
56  adj.clear();
57  rval = mb.get_adjacencies( &*i, 1, 1, false, adj );
58  if( MB_SUCCESS != rval ) return 2;
59  assert( adj.size() > 3 );
60  }
61  clock_t t_down = clock() - t_0;
62  std::cout << "Querying of faces for " << vols.size() << " volumes: " << t_down / (double)CLOCKS_PER_SEC
63  << " seconds" << std::endl;
64 
65  return 0;
66 }

References moab::Range::begin(), default_input_file, moab::Range::empty(), moab::Range::end(), ErrorCode, moab::Core::get_adjacencies(), moab::Core::get_entities_by_dimension(), moab::Core::load_file(), mb, MB_SUCCESS, moab::Range::size(), and moab::Interface::UNION.

Variable Documentation

◆ default_input_file

const std::string default_input_file = TestDir + "unittest/64bricks_512hex.h5m"
static

Definition at line 10 of file adj_time.cpp.

Referenced by main().