Loading [MathJax]/extensions/tex2jax.js
Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sphere_decomp.cpp
Go to the documentation of this file.
1 /* 2  * Sphere decomp tool. Meshes a group of spheres and the interstices between with 3  * hex elements, by triangulating the vertices corresponding to sphere centers 4  * and subdividing those tets. For a description of the subdivision template used, 5  * see comments in the subdivide_tet function below. 6  */ 7  8 #include "moab/Core.hpp" 9 #include "SphereDecomp.hpp" 10 #include <iostream> 11  12 const char* SPHERE_RADII_TAG_NAME = "SPHERE_RADII"; 13  14 #define RR \ 15  if( moab::MB_SUCCESS != result ) return result 16  17 int main( int argc, char* argv[] ) 18 { 19  if( argc < 3 ) 20  { 21  std::cout << "Usage: " << argv[0] << " <input_mesh> <output_mesh>" << std::endl; 22  return 0; 23  } 24  25  // create MOAB 26  moab::Interface* mbImpl = new moab::Core(); 27  28  // read in mesh 29  moab::ErrorCode result = mbImpl->load_mesh( argv[1] ); 30  if( moab::MB_SUCCESS != result ) 31  { 32  std::cout << "Problems loading mesh." << std::endl; 33  return 1; 34  } 35  36  moab::Tag sphere_radii_tag = 0; 37  double dum_val = 0.1; 38  result = mbImpl->tag_get_handle( SPHERE_RADII_TAG_NAME, 1, moab::MB_TYPE_DOUBLE, sphere_radii_tag, 39  moab::MB_TAG_DENSE | moab::MB_TAG_CREAT, &dum_val ); 40  if( moab::MB_SUCCESS != result ) 41  { 42  std::cout << "Problem allocating SPHERE_RADII tag." << std::endl; 43  return 1; 44  } 45  46  SphereDecomp sd( mbImpl ); 47  48  moab::EntityHandle this_set = 0; 49  result = sd.build_sphere_mesh( SPHERE_RADII_TAG_NAME, &this_set );RR; 50  51  // write mesh 52  result = mbImpl->write_mesh( argv[2], &this_set, 1 );RR; 53  54  return 0; 55 }