mesh_tools.h
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 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 00037 namespace libMesh 00038 { 00039 00040 // forward declarations 00041 class SerialMesh; 00042 class ParallelMesh; 00043 class Sphere; 00044 class Elem; 00045 template <typename T> class LocationMap; 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 00078 const Point & min() const 00079 { return this->first; } 00080 00081 Point & min() 00082 { return this->first; } 00083 00084 const Point & max() const 00085 { return this->second; } 00086 00087 Point & max() 00088 { return this->second; } 00089 00090 BoundingBox & expand() 00091 { return *this; } 00092 00093 bool intersect (const BoundingBox &) const; 00094 00095 bool contains_point (const Point &) const; 00096 00097 private: 00098 }; 00099 00106 dof_id_type total_weight (const MeshBase &mesh); 00107 00114 dof_id_type weight (const MeshBase &mesh, const processor_id_type pid=libMesh::processor_id()); 00115 00122 void build_nodes_to_elem_map (const MeshBase &mesh, 00123 std::vector<std::vector<dof_id_type> > &nodes_to_elem_map); 00124 00128 void build_nodes_to_elem_map (const MeshBase &mesh, 00129 std::vector<std::vector<const Elem*> >& nodes_to_elem_map); 00130 00131 00132 // /** 00133 // * Calling this function on a 2D mesh will convert all the elements 00134 // * to triangles. \p QUAD4s will be converted to \p TRI3s, \p QUAD8s 00135 // * and \p QUAD9s will be converted to \p TRI6s. 00136 // */ 00137 // void all_tri (MeshBase &mesh); 00138 00143 void find_boundary_nodes (const MeshBase &mesh, 00144 std::vector<bool> &on_boundary); 00145 00151 BoundingBox 00152 bounding_box (const MeshBase &mesh); 00153 00157 Sphere 00158 bounding_sphere (const MeshBase &mesh); 00159 00164 BoundingBox 00165 processor_bounding_box (const MeshBase &mesh, 00166 const processor_id_type pid); 00167 00171 Sphere 00172 processor_bounding_sphere (const MeshBase &mesh, 00173 const processor_id_type pid); 00174 00179 BoundingBox 00180 subdomain_bounding_box (const MeshBase &mesh, 00181 const subdomain_id_type sid); 00182 00186 Sphere 00187 subdomain_bounding_sphere (const MeshBase &mesh, 00188 const subdomain_id_type sid); 00189 00190 00195 void elem_types (const MeshBase &mesh, 00196 std::vector<ElemType> &et); 00197 00202 dof_id_type n_elem_of_type (const MeshBase &mesh, 00203 const ElemType type); 00204 00209 dof_id_type n_active_elem_of_type (const MeshBase &mesh, 00210 const ElemType type); 00211 00220 dof_id_type n_non_subactive_elem_of_type_at_level(const MeshBase &mesh, 00221 const ElemType type, 00222 const unsigned int level); 00223 00229 unsigned int n_levels(const MeshBase &mesh); 00230 00236 unsigned int n_local_levels(const MeshBase &mesh); 00237 00243 unsigned int n_active_levels(const MeshBase &mesh); 00244 00250 unsigned int n_active_local_levels(const MeshBase &mesh); 00251 00257 unsigned int n_p_levels (const MeshBase &mesh); 00258 00265 void get_not_subactive_node_ids(const MeshBase &mesh, 00266 std::set<dof_id_type> ¬_subactive_node_ids); 00267 00272 dof_id_type n_elem (const MeshBase::const_element_iterator &begin, 00273 const MeshBase::const_element_iterator &end); 00274 00275 00280 dof_id_type n_nodes (const MeshBase::const_node_iterator &begin, 00281 const MeshBase::const_node_iterator &end); 00282 00283 00287 unsigned int max_level (const MeshBase &mesh); 00288 00289 00294 void find_nodal_neighbors(const MeshBase &mesh, const Node &n, 00295 std::vector<std::vector<const Elem*> > &nodes_to_elem_map, 00296 std::vector<const Node*> &neighbors); 00297 00304 void find_hanging_nodes_and_parents(const MeshBase &mesh, std::map<dof_id_type, std::vector<dof_id_type> > &hanging_nodes); 00305 00316 void correct_node_proc_ids(MeshBase &, LocationMap<Node> &); 00317 00318 00319 #ifdef DEBUG 00320 00324 void libmesh_assert_no_links_to_elem(const MeshBase &mesh, 00325 const Elem *bad_elem); 00326 00331 void libmesh_assert_equal_n_systems (const MeshBase &mesh); 00332 00338 void libmesh_assert_old_dof_objects (const MeshBase &mesh); 00339 00344 void libmesh_assert_valid_node_pointers (const MeshBase &mesh); 00345 00350 void libmesh_assert_valid_remote_elems (const MeshBase &mesh); 00351 00356 void libmesh_assert_valid_elem_ids (const MeshBase &mesh); 00357 00362 void libmesh_assert_valid_amr_elem_ids (const MeshBase &mesh); 00363 00374 void libmesh_assert_connected_nodes (const MeshBase &mesh); 00375 00380 void libmesh_assert_valid_dof_ids (const MeshBase &mesh); 00381 00390 template <typename DofObjectSubclass> 00391 void libmesh_assert_valid_procids (const MeshBase &mesh); 00392 00397 void libmesh_assert_valid_refinement_flags (const MeshBase &mesh); 00398 00403 void libmesh_assert_valid_refinement_tree (const MeshBase &mesh); 00404 00409 void libmesh_assert_valid_neighbors (const MeshBase &mesh); 00410 #endif 00411 00412 // There is no reason for users to call functions in the MeshTools::Private namespace. 00413 namespace Private { 00425 void globally_renumber_nodes_and_elements (MeshBase &); 00426 } // end namespace Private 00427 00428 } // end namespace MeshTools 00429 00430 } // namespace libMesh 00431 00432 00433 #endif // LIBMESH_MESH_TOOLS_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:47 UTC
Hosted By: