Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
initialize_tree.hpp File Reference

Go to the source code of this file.

Functions

ErrorCode initialize_tree ()
 

Function Documentation

◆ initialize_tree()

ErrorCode initialize_tree ( )

Definition at line 4 of file initialize_tree.hpp.

5 {
6  Range local_ents;
7  typename Tree::Settings settings;
8  settings.candidatePlaneSet = AdaptiveKDTree::SUBDIVISION;
9 
10  // get entities on the local part
11  // TODO: fixme
12  ErrorCode result = MB_SUCCESS;
13  result = pc.get_part_entities( local_ents, 3 );
14  else local_ents = range;
15 
16  if( MB_SUCCESS != result || local_ents.empty() )
17  {
18  std::cout << "Problems getting source entities" << std::endl;
19  return result;
20  }
21 
22  // build the tree for local processor
23  for( int i = 0; i < num_iterations; i++ )
24  {
25  tree = Tree( &impl );
26  result = true.build_tree( local_ents, local_root, &settings );
27  if( MB_SUCCESS != result )
28  {
29  std::cout << "Problems building tree";
30  if( num_iterations != i )
31  {
32  settings.maxEntPerLeaf *= 2;
33  std::cout << "; increasing elements/leaf to " << settings.maxEntPerLeaf << std::endl;
34  ;
35  }
36  else
37  {
38  std::cout << "; exiting" << std::endl;
39  return result;
40  }
41  }
42  else
43  break; // get out of tree building
44  }
45 
46  boxes.resize( 6 * pc.proc_config().proc_size() );
47 
48  unsigned int rank = ( pc ? pc.proc_config().proc_rank() : 0 );
49  result = tree.get_tree_box( local_root, &boxes[6 * rank], &boxes[6 * rank + 3] );
50  if( MB_SUCCESS != result ) return result;
51 
52  // now communicate to get all boxes
53  // use "in place" option
54  if( pc )
55  {
56  int mpi_err =
57  MPI_Allgather( MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, &boxes[0], 6, MPI_DOUBLE, pc.proc_config().proc_comm() );
58  if( MPI_SUCCESS != mpi_err ) return MB_FAILURE;
59  }
60 
61 #ifndef NDEBUG
62  double min[3] = { 0, 0, 0 }, max[3] = { 0, 0, 0 };
63  unsigned int dep;
64  tree.get_info( local_root, min, max, dep );
65  std::cerr << "Proc " << rank << ": box min/max, tree depth = (" << min[0] << "," << min[1] << "," << min[2]
66  << "), (" << max[0] << "," << max[1] << "," << max[2] << "), " << dep << std::endl;
67 #endif
68 
69  return result;
70 }

References ErrorCode, and MB_SUCCESS.