LCOV - code coverage report
Current view: top level - include/mesh - mesh_tetgen_wrapper.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 1 1 100.0 %
Date: 2025-08-19 19:27:09 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // The libMesh Finite Element Library.
       2             : // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
       3             : 
       4             : // This library is free software; you can redistribute it and/or
       5             : // modify it under the terms of the GNU Lesser General Public
       6             : // License as published by the Free Software Foundation; either
       7             : // version 2.1 of the License, or (at your option) any later version.
       8             : 
       9             : // This library is distributed in the hope that it will be useful,
      10             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12             : // Lesser General Public License for more details.
      13             : 
      14             : // You should have received a copy of the GNU Lesser General Public
      15             : // License along with this library; if not, write to the Free Software
      16             : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      17             : 
      18             : #ifndef LIBMESH_MESH_TETGEN_WRAPPER_H
      19             : #define LIBMESH_MESH_TETGEN_WRAPPER_H
      20             : 
      21             : #include "libmesh/libmesh_config.h"
      22             : #ifdef LIBMESH_HAVE_TETGEN
      23             : 
      24             : // TetGen include file
      25             : // tetgen.h triggers -Werror=switch-default
      26             : #include "libmesh/ignore_warnings.h"
      27             : #include "tetgen.h"  // Defines REAL and other Tetgen types
      28             : #include "libmesh/restore_warnings.h"
      29             : 
      30             : // C++ includes
      31             : #include <string>
      32             : #include <memory>
      33             : 
      34             : namespace libMesh
      35             : {
      36             : /**
      37             :  * The \p TetGenWrapper provides an interface for basic
      38             :  * access to TetGen data structures and methods.
      39             :  *
      40             :  * \author Steffen Petersen
      41             :  * \date 2004
      42             :  * \author John W. Peterson
      43             :  * \date 2011
      44             :  */
      45        1638 : class TetGenWrapper
      46             : {
      47             : public:
      48             : 
      49             :   /**
      50             :    * Constructor.
      51             :    */
      52             :   TetGenWrapper ();
      53             : 
      54             :   /**
      55             :    * Destructor.  Empty.
      56             :    */
      57             :   ~TetGenWrapper ();
      58             : 
      59             :   /**
      60             :    * Method to set TetGen commandline switches
      61             :    * -p Tetrahedralizes a piecewise linear complex (.poly or .smesh file).
      62             :    * -q Quality mesh generation. A minimum radius-edge ratio may be specified (default 2.0).
      63             :    * -a Applies a maximum tetrahedron volume constraint.
      64             :    * -A Assigns attributes to identify tetrahedra in certain regions.
      65             :    * -r Reconstructs and Refines a previously generated mesh.
      66             :    * -Y Suppresses boundary facets/segments splitting.
      67             :    * -i Inserts a list of additional points into mesh.
      68             :    * -M Does not merge coplanar facets.
      69             :    * -T Set a tolerance for coplanar test (default 1e-8).
      70             :    * -d Detect intersections of PLC facets.
      71             :    * -z Numbers all output items starting from zero.
      72             :    * -o2 Generates second-order subparametric elements.
      73             :    * -f Outputs faces (including non-boundary faces) to .face file.
      74             :    * -e Outputs subsegments to .edge file.
      75             :    * -n Outputs tetrahedra neighbors to .neigh file.
      76             :    * -g Outputs mesh to .mesh file for viewing by Medit.
      77             :    * -G Outputs mesh to .msh file for viewing by Gid.
      78             :    * -O Outputs mesh to .off file for viewing by Geomview.
      79             :    * -J No jettison of unused vertices from output .node file.
      80             :    * -B Suppresses output of boundary information.
      81             :    * -N Suppresses output of .node file.
      82             :    * -E Suppresses output of .ele file.
      83             :    * -F Suppresses output of .face file.
      84             :    * -I Suppresses mesh iteration numbers.
      85             :    * -C Checks the consistency of the final mesh.
      86             :    * -Q Quiet: No terminal output except errors.
      87             :    * -V Verbose: Detailed information, more terminal output.
      88             :    * -v Prints the version information.
      89             :    * -h Help: A brief instruction for using TetGen.
      90             :    */
      91             :   void set_switches(std::string_view s);
      92             : 
      93             :   /**
      94             :    * Starts the triangulation.
      95             :    */
      96             :   void run_tetgen();
      97             : 
      98             :   /**
      99             :    * \returns Number of tetrahedra in the TetGen output.
     100             :    */
     101             :   int  get_numberoftetrahedra();
     102             : 
     103             :   /**
     104             :    * \returns Number of triangle surface elements in the TetGen output.
     105             :    */
     106             :   int  get_numberoftrifaces();
     107             : 
     108             :   /**
     109             :    * Sets the number of nodes in the TetGen input.
     110             :    */
     111             :   void set_numberofpoints(int i);
     112             : 
     113             :   /**
     114             :    * \returns Number of nodes in the TetGen output.
     115             :    */
     116             :   int get_numberofpoints();
     117             : 
     118             :   /**
     119             :    * Sets the number of facets in the TetGen input.
     120             :    */
     121             :   void set_numberoffacets(int i);
     122             : 
     123             :   /**
     124             :    * Sets the number of holes in the TetGen input.
     125             :    */
     126             :   void set_numberofholes(int i);
     127             : 
     128             :   /**
     129             :    * Sets the number of regions in the TetGen input.
     130             :    */
     131             :   void set_numberofregions(int i);
     132             : 
     133             :   /**
     134             :    * Allocates memory, sets number of nodes in the TetGen input.
     135             :    */
     136             :   void allocate_pointlist(int numofpoints);
     137             : 
     138             :   /**
     139             :    * Allocates memory, sets number of facets, holes in the TetGen input.
     140             :    */
     141             :   void allocate_facetlist(int numoffacets, int numofholes);
     142             : 
     143             :   /**
     144             :    * Allocates memory, sets number of regions in the TetGen input.
     145             :    */
     146             :   void allocate_regionlist(int numofregions);
     147             : 
     148             :   /**
     149             :    * Sets coordinates of point i in the TetGen input.
     150             :    */
     151             :   void set_node(unsigned i, REAL x, REAL y, REAL z);
     152             : 
     153             :   /**
     154             :    * \returns The coordinates of point i in the TetGen output.
     155             :    */
     156             :   void get_output_node(unsigned i, REAL & x, REAL & y, REAL & z);
     157             : 
     158             :   /**
     159             :    * \returns The index of jth node from element i in the TetGen output.
     160             :    */
     161             :   int  get_element_node(unsigned i, unsigned j);
     162             : 
     163             :   /**
     164             :    * \returns The index of the jth node from surface triangle i in the TetGen output.
     165             :    */
     166             :   int  get_triface_node(unsigned i, unsigned j);
     167             : 
     168             :   /**
     169             :    * \returns The attribute of element i in the TetGen output.
     170             :    */
     171             :   REAL get_element_attribute(unsigned i);
     172             : 
     173             :   /**
     174             :    * Sets coordinates of hole i in the TetGen input.
     175             :    */
     176             :   void set_hole(unsigned i, REAL x, REAL y, REAL z);
     177             : 
     178             :   /**
     179             :    * Sets the number of polygons for facet i in the TetGen input.
     180             :    */
     181             :   void set_facet_numberofpolygons(unsigned i, int num);
     182             : 
     183             :   /**
     184             :    * Sets the number of holes for facet i in the TetGen input.
     185             :    */
     186             :   void set_facet_numberofholes(unsigned i, int num);
     187             : 
     188             :   /**
     189             :    * Allocates memory, sets number of polygons for facet i
     190             :    * in the TetGen input.
     191             :    */
     192             :   void allocate_facet_polygonlist(unsigned i, int numofpolygons);
     193             : 
     194             :   /**
     195             :    * Sets the number of vertices for polygon j, facet i in the TetGen input.
     196             :    */
     197             :   void set_polygon_numberofvertices(unsigned i, unsigned j, int num);
     198             : 
     199             :   /**
     200             :    * Allocates memory, sets number of vertices for polygon j,
     201             :    * facet i in the TetGen input.
     202             :    */
     203             :   void allocate_polygon_vertexlist(unsigned i, unsigned j, int numofvertices);
     204             : 
     205             :   /**
     206             :    * Sets index of ith facet, jth polygon, kth vertex in
     207             :    * the TetGen input.
     208             :    */
     209             :   void set_vertex(unsigned i, unsigned j, unsigned k, int nodeindex);
     210             : 
     211             :   /**
     212             :    * Sets coordinates, attribute, and volume constraint for region i
     213             :    * in the TetGen input.
     214             :    *
     215             :    * \note Coordinates and attributes will only be considered if the
     216             :    * corresponding switches are enabled.  See TetGen documentation for
     217             :    * more details.
     218             :    */
     219             :   void set_region(unsigned i, REAL x, REAL y, REAL z,
     220             :                   REAL attribute, REAL vol_constraint);
     221             : 
     222             :   /**
     223             :    * TetGen input structure.
     224             :    */
     225             :   tetgenio   tetgen_data;
     226             : 
     227             :   /**
     228             :    * TetGen output structure.
     229             :    */
     230             :   std::unique_ptr<tetgenio> tetgen_output;
     231             : 
     232             :   /**
     233             :    * TetGen mesh structure (from the TetGen library).
     234             :    */
     235             :   tetgenmesh      tetgen_mesh;
     236             : 
     237             :   /**
     238             :    * TetGen control class (from the TetGen library).
     239             :    */
     240             :   tetgenbehavior  tetgen_be;
     241             : };
     242             : 
     243             : 
     244             : 
     245             : } // namespace libMesh
     246             : 
     247             : 
     248             : #endif // LIBMESH_HAVE_TETGEN
     249             : #endif // LIBMESH_MESH_TETGEN_WRAPPER_H

Generated by: LCOV version 1.14