Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
UniformRefinement.cpp
Go to the documentation of this file.
1 /*This unit test is for the uniform refinement capability based on AHF datastructures*/
2 #include <iostream>
3 #include "moab/Core.hpp"
4 #include "moab/NestedRefine.hpp"
5 
6 using namespace moab;
7 
8 int main( int argc, char* argv[] )
9 {
10  Core mb;
11  Interface* mbImpl = &mb;
13 
14  if( argc == 1 )
15  {
16  std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
17  return 1;
18  }
19 
20  const char* filename = argv[1];
21  error = mbImpl->load_file( filename );MB_CHK_ERR( error );
22 
23  NestedRefine uref( &mb );
24 
25  // Usage: The level degrees array controls number of refinemetns and
26  // the degree of refinement at each level.
27  // Example: int level_degrees[4] = {2,3,2,3};
28  std::vector< int > level_degrees;
29  if( argc > 2 )
30  {
31  level_degrees.resize( argc - 2 );
32  for( int i = 2; i < argc; ++i )
33  level_degrees[i - 2] = atoi( argv[i] );
34  }
35  else
36  {
37  level_degrees.resize( 2 );
38  }
39  int num_levels = static_cast< int >( level_degrees.size() );
40 
41  std::cout << "Starting hierarchy generation" << std::endl;
42  std::vector< EntityHandle > set;
43  error = uref.generate_mesh_hierarchy( num_levels, level_degrees.data(), set );MB_CHK_ERR( error );
44  std::cout << "Finished hierarchy generation" << std::endl;
45 
46  std::stringstream file;
47  file << "mesh_hierarchy.h5m";
48  error = mbImpl->write_file( file.str().c_str() );MB_CHK_ERR( error );
49  return 0;
50 }