1 // The libMesh Finite Element Library. 2 // Copyright (C) 2002-2020 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 20 #ifndef LIBMESH_UNSTRUCTURED_MESH_H 21 #define LIBMESH_UNSTRUCTURED_MESH_H 22 23 // Local Includes 24 #include "libmesh/mesh_base.h" 25 26 // C++ Includes 27 #include <cstddef> 28 29 namespace libMesh 30 { 31 32 /** 33 * The \p UnstructuredMesh class is derived from the \p MeshBase class. The 34 * user will typically want to instantiate and use the 35 * Mesh class in her applications, which is currently a simple 36 * derived class of UnstructuredMesh. 37 * In order to use the adaptive mesh refinement capabilities 38 * of the library, first instantiate a MeshRefinement object 39 * with a reference to this class. Then call the appropriate 40 * refinement functions from that object. To interact with the 41 * boundary, instantiate a BoundaryMesh with a reference to 42 * this class, and then use that object's functionality. 43 * 44 * \author Roy Stogner 45 * \date 2007 46 * \brief Base class for Replicated and Distributed meshes. 47 */ 48 class UnstructuredMesh : public MeshBase 49 { 50 public: 51 52 /** 53 * Constructor. Takes \p dim, the dimension of the mesh. 54 * The mesh dimension can be changed (and may automatically be 55 * changed by mesh generation/loading) later. 56 */ 57 explicit 58 UnstructuredMesh (const Parallel::Communicator & comm_in, 59 unsigned char dim=1); 60 61 /** 62 * UnstructuredMesh uses a defaulted copy constructor. 63 */ 64 UnstructuredMesh(const UnstructuredMesh &) = default; 65 66 /** 67 * Move-constructor deleted in MeshBase. 68 */ 69 UnstructuredMesh(UnstructuredMesh &&) = delete; 70 71 /** 72 * Copy and move assignment are not allowed. 73 */ 74 UnstructuredMesh & operator= (const UnstructuredMesh &) = delete; 75 UnstructuredMesh & operator= (UnstructuredMesh &&) = delete; 76 77 /** 78 * Destructor. 79 */ 80 virtual ~UnstructuredMesh(); 81 82 /** 83 * Reads the file specified by \p name. Attempts to figure out the 84 * proper method by the file extension. This is now the only 85 * way to read a mesh. The \p UnstructuredMesh then initializes its data 86 * structures and is ready for use. 87 * 88 * The skip_renumber_nodes_and_elements argument is now deprecated - 89 * to disallow renumbering, set \p MeshBase::allow_renumbering(false). 90 * 91 * Set skip_find_neighbors=true to skip the find-neighbors operation 92 * during prepare_for_use. This operation isn't always necessary 93 * and it can be time-consuming, which is why we provide an option to 94 * skip it. 95 */ 96 virtual void read (const std::string & name, 97 void * mesh_data=nullptr, 98 bool skip_renumber_nodes_and_elements=false, 99 bool skip_find_neighbors=false) override; 100 /** 101 * Write the file specified by \p name. Attempts to figure out the 102 * proper method by the file extension. 103 */ 104 virtual void write (const std::string & name) override; 105 106 /** 107 * Write to the file specified by \p name. Attempts to figure out the 108 * proper method by the file extension. Also writes data. 109 */ 110 void write (const std::string & name, 111 const std::vector<Number> & values, 112 const std::vector<std::string> & variable_names); 113 114 /** 115 * Converts a mesh with higher-order 116 * elements into a mesh with linear elements. For 117 * example, a mesh consisting of \p Tet10 will be converted 118 * to a mesh with \p Tet4 etc. 119 */ 120 virtual void all_first_order () override; 121 122 /** 123 * Converts a (conforming, non-refined) mesh with linear elements 124 * into a mesh with second-order elements. For example, a mesh 125 * consisting of \p Tet4 will be converted to a mesh with \p Tet10 126 * etc. 127 * 128 * \note For some elements like \p Hex8 there exist two higher order 129 * equivalents, \p Hex20 and \p Hex27. When \p full_ordered is \p 130 * true (default), then \p Hex27 is built. Otherwise, \p Hex20 is 131 * built. The same holds obviously for \p Quad4, \p Prism6, etc. 132 */ 133 virtual void all_second_order (const bool full_ordered=true) override; 134 135 /** 136 * Generates a new mesh containing all the elements which 137 * are assigned to processor \p pid. This mesh is written 138 * to the pid_mesh reference which you must create and pass 139 * to the function. 140 */ 141 void create_pid_mesh (UnstructuredMesh & pid_mesh, 142 const processor_id_type pid) const; 143 144 /** 145 * Constructs a mesh called "new_mesh" from the current mesh by 146 * iterating over the elements between it and it_end and adding 147 * them to the new mesh. 148 */ 149 void create_submesh (UnstructuredMesh & new_mesh, 150 const const_element_iterator & it, 151 const const_element_iterator & it_end) const; 152 153 154 /** 155 * Deep copy of nodes and elements from another unstructured mesh 156 * class (used by subclass copy constructors and by mesh merging 157 * operations) 158 * 159 * This will not copy most "high level" data in the mesh; that is 160 * done separately by constructors. An exception is that, if the 161 * \p other_mesh has element or node extra_integer data, any names 162 * for that data which do not already exist on \p this mesh are 163 * added so that all such data can be copied. 164 */ 165 virtual void copy_nodes_and_elements (const UnstructuredMesh & other_mesh, 166 const bool skip_find_neighbors = false, 167 dof_id_type element_id_offset = 0, 168 dof_id_type node_id_offset = 0, 169 unique_id_type unique_id_offset = 0); 170 171 172 /** 173 * Other functions from MeshBase requiring re-definition. 174 */ 175 virtual void find_neighbors (const bool reset_remote_elements = false, 176 const bool reset_current_list = true) override; 177 178 #ifdef LIBMESH_ENABLE_AMR 179 /** 180 * Delete subactive (i.e. children of coarsened) elements. 181 * This removes all elements descended from currently active 182 * elements in the mesh. 183 */ 184 virtual bool contract () override; 185 #endif // #ifdef LIBMESH_ENABLE_AMR 186 187 }; 188 189 190 } // namespace libMesh 191 192 #endif // LIBMESH_UNSTRUCTURED_MESH_H 193