$extrastylesheet
00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 00019 00020 #ifndef LIBMESH_MESH_TOOLS_H 00021 #define LIBMESH_MESH_TOOLS_H 00022 00023 00024 00025 // Local Includes ----------------------------------- 00026 #include "libmesh/libmesh.h" 00027 #include "libmesh/enum_elem_type.h" 00028 #include "libmesh/id_types.h" 00029 #include "libmesh/mesh_base.h" 00030 #include "libmesh/point.h" // some compilers want the full definition - I think so they can do 00031 // return-value-optimization for BoundingBox'es - BSK 00032 00033 // C++ Includes ----------------------------------- 00034 #include <vector> 00035 #include <set> 00036 #include <limits> 00037 00038 namespace libMesh 00039 { 00040 00041 // forward declarations 00042 class SerialMesh; 00043 class ParallelMesh; 00044 class Sphere; 00045 class Elem; 00046 00058 // ------------------------------------------------------------ 00059 // MeshTools namespace 00060 namespace MeshTools 00061 { 00066 class BoundingBox : public std::pair<Point, Point> 00067 { 00068 public: 00069 00070 BoundingBox (const Point &new_min, const Point &new_max) : 00071 std::pair<Point, Point>(new_min, new_max) 00072 {} 00073 00074 BoundingBox (const std::pair<Point, Point> &bbox) : 00075 std::pair<Point, Point> (bbox) 00076 {} 00077 00081 BoundingBox () 00082 { 00083 this->invalidate(); 00084 } 00085 00086 void invalidate () 00087 { 00088 for (unsigned int i=0; i<LIBMESH_DIM; i++) 00089 { 00090 this->first(i) = std::numeric_limits<Real>::max(); 00091 this->second(i) = -std::numeric_limits<Real>::max(); 00092 } 00093 } 00094 00095 const Point & min() const 00096 { return this->first; } 00097 00098 Point & min() 00099 { return this->first; } 00100 00101 const Point & max() const 00102 { return this->second; } 00103 00104 Point & max() 00105 { return this->second; } 00106 00107 BoundingBox & expand() 00108 { return *this; } 00109 00110 bool intersect (const BoundingBox &) const; 00111 00112 bool contains_point (const Point &) const; 00113 00114 private: 00115 }; 00116 00123 dof_id_type total_weight (const MeshBase &mesh); 00124 00131 dof_id_type weight (const MeshBase &mesh, const processor_id_type pid); 00132 00133 inline 00134 dof_id_type weight (const MeshBase &mesh) 00135 { return MeshTools::weight (mesh, mesh.processor_id()); } 00136 00143 void build_nodes_to_elem_map (const MeshBase &mesh, 00144 std::vector<std::vector<dof_id_type> > &nodes_to_elem_map); 00145 00149 void build_nodes_to_elem_map (const MeshBase &mesh, 00150 std::vector<std::vector<const Elem*> >&nodes_to_elem_map); 00151 00152 00153 // /** 00154 // * Calling this function on a 2D mesh will convert all the elements 00155 // * to triangles. \p QUAD4s will be converted to \p TRI3s, \p QUAD8s 00156 // * and \p QUAD9s will be converted to \p TRI6s. 00157 // */ 00158 // void all_tri (MeshBase &mesh); 00159 00164 void find_boundary_nodes (const MeshBase &mesh, 00165 std::vector<bool> &on_boundary); 00166 00172 BoundingBox 00173 bounding_box (const MeshBase &mesh); 00174 00178 Sphere 00179 bounding_sphere (const MeshBase &mesh); 00180 00185 BoundingBox 00186 processor_bounding_box (const MeshBase &mesh, 00187 const processor_id_type pid); 00188 00192 Sphere 00193 processor_bounding_sphere (const MeshBase &mesh, 00194 const processor_id_type pid); 00195 00200 BoundingBox 00201 subdomain_bounding_box (const MeshBase &mesh, 00202 const subdomain_id_type sid); 00203 00207 Sphere 00208 subdomain_bounding_sphere (const MeshBase &mesh, 00209 const subdomain_id_type sid); 00210 00211 00216 void elem_types (const MeshBase &mesh, 00217 std::vector<ElemType> &et); 00218 00223 dof_id_type n_elem_of_type (const MeshBase &mesh, 00224 const ElemType type); 00225 00230 dof_id_type n_active_elem_of_type (const MeshBase &mesh, 00231 const ElemType type); 00232 00241 dof_id_type n_non_subactive_elem_of_type_at_level(const MeshBase &mesh, 00242 const ElemType type, 00243 const unsigned int level); 00244 00250 unsigned int n_levels(const MeshBase &mesh); 00251 00257 unsigned int n_local_levels(const MeshBase &mesh); 00258 00264 unsigned int n_active_levels(const MeshBase &mesh); 00265 00271 unsigned int n_active_local_levels(const MeshBase &mesh); 00272 00278 unsigned int n_p_levels (const MeshBase &mesh); 00279 00286 void get_not_subactive_node_ids(const MeshBase &mesh, 00287 std::set<dof_id_type> ¬_subactive_node_ids); 00288 00293 dof_id_type n_elem (const MeshBase::const_element_iterator &begin, 00294 const MeshBase::const_element_iterator &end); 00295 00296 00301 dof_id_type n_nodes (const MeshBase::const_node_iterator &begin, 00302 const MeshBase::const_node_iterator &end); 00303 00304 00308 unsigned int max_level (const MeshBase &mesh); 00309 00310 00315 void find_nodal_neighbors(const MeshBase &mesh, const Node &n, 00316 std::vector<std::vector<const Elem*> > &nodes_to_elem_map, 00317 std::vector<const Node*> &neighbors); 00318 00325 void find_hanging_nodes_and_parents(const MeshBase &mesh, std::map<dof_id_type, std::vector<dof_id_type> > &hanging_nodes); 00326 00337 void correct_node_proc_ids(MeshBase &); 00338 00339 00340 #ifdef DEBUG 00341 00345 void libmesh_assert_no_links_to_elem(const MeshBase &mesh, 00346 const Elem *bad_elem); 00347 00352 void libmesh_assert_equal_n_systems (const MeshBase &mesh); 00353 00359 void libmesh_assert_old_dof_objects (const MeshBase &mesh); 00360 00365 void libmesh_assert_valid_node_pointers (const MeshBase &mesh); 00366 00371 void libmesh_assert_valid_remote_elems (const MeshBase &mesh); 00372 00377 void libmesh_assert_valid_elem_ids (const MeshBase &mesh); 00378 00383 void libmesh_assert_valid_amr_elem_ids (const MeshBase &mesh); 00384 00395 void libmesh_assert_connected_nodes (const MeshBase &mesh); 00396 00401 void libmesh_assert_valid_dof_ids (const MeshBase &mesh); 00402 00411 template <typename DofObjectSubclass> 00412 void libmesh_assert_valid_procids (const MeshBase &mesh); 00413 00418 void libmesh_assert_valid_refinement_flags (const MeshBase &mesh); 00419 00424 void libmesh_assert_valid_refinement_tree (const MeshBase &mesh); 00425 00430 void libmesh_assert_valid_neighbors (const MeshBase &mesh); 00431 #endif 00432 00433 // There is no reason for users to call functions in the MeshTools::Private namespace. 00434 namespace Private { 00446 void globally_renumber_nodes_and_elements (MeshBase &); 00447 } // end namespace Private 00448 00449 } // end namespace MeshTools 00450 00451 } // namespace libMesh 00452 00453 00454 #endif // LIBMESH_MESH_TOOLS_H