Content  


Different mesh generation tools support different mesh generation tasks. This examples demonstrates the abstract common interface of ViennaMesh.

Simple API example
  1. SomeDomainType hull_domain;
  2. SomeOtherSomeType volume_domain;
  3.  
  4. viennamesh::resulf_of::settings< some_mesher_tag > settings;
  5.  
  6. viennamesh::run_algo< some_mesher_tag >( hull_domain, volume_domain, settings );

A more concrete example is given below. At first, a PLC file is read (using a TETGEN .poly file). This PLC is meshed to a hull and than further meshed to a volume mesh using a scalar field for the element size.

PLC to Volume Meshing Example
  1. // simple functor for mesh cell size
  2. struct functor
  3. {
  4. template<typename point_type>
  5. double operator() (point_type const & p) const
  6. { return p[0] / 10.0 * 2.0 + 0.2; }
  7. };
  8.  
  9. int main()
  10. {
  11. viennagrid::config::plc_3d_domain plc_domain;
  12.  
  13. // reading a simple cube in the PLC domain
  14. viennagrid::io::poly_reader reader;
  15. reader(plc_domain, "cube.poly");
  16.  
  17. viennagrid::config::triangular_3d_domain triangle_domain;
  18. // defining the settings for PLC meshing
  19. viennamesh::result_of::settings<viennamesh::cgal_plc_3d_mesher_tag>::type plc_settings;
  20. // actual PLC -> triangular hull meshing
  21. viennamesh::run_algo< viennamesh::cgal_plc_3d_mesher_tag >( plc_domain,
  22. triangle_domain,
  23. plc_settings );
  24.  
  25. // defining the settings for tetrahedron volume meshing
  26. viennamesh::result_of::settings<viennamesh::cgal_delaunay_tetrahedron_tag>::type tet_settings;
  27. // configuring the settings
  28. functor f;
  29. tet_settings.cell_size = f; // assigning functor is possible...
  30. tet_settings.cell_radius_edge_ratio = 1.5; // ... as well as simple double values
  31. viennagrid::config::tetrahedral_3d_domain tet_domain;
  32. // actual triangular hull -> tetrahedron volume meshing
  33. viennamesh::run_algo<viennamesh::cgal_delaunay_tetrahedron_tag>( triangle_domain,
  34. tet_domain,
  35. tet_settings );
  36.  
  37. // writing output to VTK file
  38. viennagrid::io::vtk_writer<viennagrid::config::tetrahedral_3d_domain,
  39. viennagrid::config::tetrahedral_3d_cell>
  40. vtk_volume_writer;
  41. vtk_volume_writer(tet_domain, "cube_poly_meshed.vtu");
  42. }