Line data Source code
1 : // The libMesh Finite Element Library. 2 : // Copyright (C) 2002-2023 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 : 19 : #ifndef LIBMESH_MESH_TET_INTERFACE_H 20 : #define LIBMESH_MESH_TET_INTERFACE_H 21 : 22 : #include "libmesh/libmesh_config.h" 23 : 24 : // Local includes 25 : #include "libmesh/bounding_box.h" 26 : #include "libmesh/enum_elem_type.h" 27 : #include "libmesh/point.h" // used for specifying holes 28 : 29 : // C++ includes 30 : #include <cstddef> 31 : #include <map> 32 : #include <memory> 33 : #include <string> 34 : #include <vector> 35 : 36 : namespace libMesh 37 : { 38 : // Forward Declarations 39 : class UnstructuredMesh; 40 : class Elem; 41 : 42 : /** 43 : * Class \p MeshTetInterface provides an abstract interface for 44 : * tetrahedralization of meshes by subclasses. 45 : * 46 : * \author Roy H. Stogner 47 : * \date 2024 48 : */ 49 52 : class MeshTetInterface 50 : { 51 : public: 52 : 53 : /** 54 : * Constructor. Takes a reference to the mesh. 55 : */ 56 : explicit 57 : MeshTetInterface (UnstructuredMesh & mesh); 58 : 59 : /** 60 : * Default destructor in base class. 61 : */ 62 : virtual ~MeshTetInterface(); 63 : 64 : /** 65 : * Sets and/or gets the desired tetrahedron volume. Set to zero to 66 : * disable volume constraint. 67 : */ 68 0 : Real & desired_volume() {return _desired_volume;} 69 : 70 : /** 71 : * Sets/gets flag which tells whether to do two steps of Laplace 72 : * mesh smoothing after generating the grid. False by default (for 73 : * compatibility with old TetGenMeshInterface behavior). 74 : */ 75 : bool & smooth_after_generating() {return _smooth_after_generating;} 76 : 77 : /** 78 : * Sets and/or gets the desired element type. This should be a Tet 79 : * type. 80 : */ 81 : ElemType & elem_type() {return _elem_type;} 82 : 83 : /** 84 : * Attaches a vector of Mesh pointers defining holes which will be 85 : * meshed around. We use unique_ptr here because we expect that we 86 : * may need to modify these meshes internally. 87 : */ 88 : void attach_hole_list(std::unique_ptr<std::vector<std::unique_ptr<UnstructuredMesh>>> holes); 89 : 90 : /** 91 : * This is the main public interface for this function. 92 : */ 93 : virtual void triangulate () = 0; 94 : 95 : protected: 96 : 97 : /** 98 : * Remove volume elements from the given mesh, after converting 99 : * their outer boundary faces to surface elements. 100 : * 101 : * Returns the bounding box of the mesh; this is useful for 102 : * detecting misplaced holes later. 103 : */ 104 : static BoundingBox volume_to_surface_mesh (UnstructuredMesh & mesh); 105 : 106 : /** 107 : * This function checks the integrity of the current set of 108 : * elements in the Mesh to see if they comprise a hull, 109 : * that is: 110 : * - If they are all TRI3 elements 111 : * - They all have non-nullptr neighbors 112 : * 113 : * \returns 114 : * - 0 if the mesh forms a valid hull 115 : * - 1 if a non-TRI3 element is found 116 : * - 2 if an element with a nullptr-neighbor is found 117 : */ 118 : unsigned check_hull_integrity(); 119 : 120 : /** 121 : * This function prints an informative message and 122 : * crashes based on the output of the check_hull_integrity() 123 : * function. It is a separate function so that you 124 : * can check hull integrity without crashing if you desire. 125 : */ 126 : void process_hull_integrity_result(unsigned result); 127 : 128 : /** 129 : * Delete original convex hull elements from the Mesh 130 : * after performing a Delaunay tetrahedralization. 131 : */ 132 : void delete_2D_hull_elements(); 133 : 134 : /** 135 : * The desired volume for the elements in the resulting mesh. 136 : * Unlimited (indicated by 0) by default 137 : */ 138 : Real _desired_volume; 139 : 140 : /** 141 : * Flag which tells whether we should smooth the mesh after 142 : * it is generated. False by default. 143 : */ 144 : bool _smooth_after_generating; 145 : 146 : /** 147 : * The exact type of tetrahedra we intend to construct 148 : */ 149 : ElemType _elem_type; 150 : 151 : /** 152 : * Local reference to the mesh we are working with. 153 : */ 154 : UnstructuredMesh & _mesh; 155 : 156 : /** 157 : * A pointer to a vector of meshes each defining a hole. If this is 158 : * nullptr, there are no holes! 159 : */ 160 : std::unique_ptr<std::vector<std::unique_ptr<UnstructuredMesh>>> _holes; 161 : }; 162 : 163 : } // namespace libMesh 164 : 165 : #endif // LIBMESH_MESH_TET_INTERFACE_H