$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_BOUNDARY_INFO_H 00021 #define LIBMESH_BOUNDARY_INFO_H 00022 00023 // Local includes 00024 #include "libmesh/libmesh_common.h" 00025 #include "libmesh/id_types.h" 00026 #include "libmesh/parallel_object.h" 00027 00028 // C++ includes 00029 #include <cstddef> 00030 #include <map> 00031 #include <set> 00032 #include <vector> 00033 00034 namespace libMesh 00035 { 00036 00037 00038 // Forward declarations 00039 class Elem; 00040 class Node; 00041 class MeshBase; 00042 class UnstructuredMesh; 00043 class MeshData; 00044 00045 00057 //------------------------------------------------------ 00058 // BoundaryInfo class definition 00059 class BoundaryInfo : public ParallelObject 00060 { 00061 protected: 00062 friend class MeshBase; 00063 00070 BoundaryInfo (const MeshBase& m); 00071 00072 public: 00078 BoundaryInfo& operator=(const BoundaryInfo& other_boundary_info); 00079 00080 00084 ~BoundaryInfo (); 00085 00091 void clear (); 00092 00105 void sync (UnstructuredMesh& boundary_mesh, 00106 MeshData* boundary_mesh_data=NULL, 00107 MeshData* this_mesh_data=NULL); 00108 00122 void sync (const std::set<boundary_id_type> &requested_boundary_ids, 00123 UnstructuredMesh& boundary_mesh, 00124 MeshData* boundary_mesh_data=NULL, 00125 MeshData* this_mesh_data=NULL); 00126 00131 void add_node (const Node* node, 00132 const boundary_id_type id); 00133 00138 void add_node (const dof_id_type node, 00139 const boundary_id_type id); 00140 00145 void add_node (const Node* node, 00146 const std::vector<boundary_id_type>& ids); 00147 00151 void clear_boundary_node_ids(); 00152 00158 void add_edge (const dof_id_type elem, 00159 const unsigned short int edge, 00160 const boundary_id_type id); 00161 00167 void add_edge (const Elem* elem, 00168 const unsigned short int edge, 00169 const boundary_id_type id); 00170 00176 void add_edge (const Elem* elem, 00177 const unsigned short int edge, 00178 const std::vector<boundary_id_type>& ids); 00179 00184 void add_side (const dof_id_type elem, 00185 const unsigned short int side, 00186 const boundary_id_type id); 00187 00192 void add_side (const Elem* elem, 00193 const unsigned short int side, 00194 const boundary_id_type id); 00195 00200 void add_side (const Elem* elem, 00201 const unsigned short int side, 00202 const std::vector<boundary_id_type>& ids); 00203 00208 void remove (const Node* node); 00209 00214 void remove (const Elem* elem); 00215 00220 void remove_edge (const Elem* elem, 00221 const unsigned short int edge); 00222 00227 void remove_edge (const Elem* elem, 00228 const unsigned short int edge, 00229 const boundary_id_type id); 00230 00235 void remove_side (const Elem* elem, 00236 const unsigned short int side); 00237 00242 void remove_side (const Elem* elem, 00243 const unsigned short int side, 00244 const boundary_id_type id); 00245 00249 std::size_t n_boundary_ids () const { return _boundary_ids.size(); } 00250 00254 bool has_boundary_id (const Node* const node, 00255 const boundary_id_type id) const; 00256 00260 std::vector<boundary_id_type> boundary_ids (const Node* node) const; 00261 00265 unsigned int n_boundary_ids (const Node* node) const; 00266 00272 unsigned int n_edge_boundary_ids (const Elem* const elem, 00273 const unsigned short int edge) const; 00274 00280 std::vector<boundary_id_type> edge_boundary_ids (const Elem* const elem, 00281 const unsigned short int edge) const; 00282 00290 std::vector<boundary_id_type> raw_edge_boundary_ids (const Elem* const elem, 00291 const unsigned short int edge) const; 00292 00297 bool has_boundary_id (const Elem* const elem, 00298 const unsigned short int side, 00299 const boundary_id_type id) const; 00300 00308 boundary_id_type boundary_id (const Elem* const elem, 00309 const unsigned short int side) const; 00310 00315 unsigned int n_boundary_ids (const Elem* const elem, 00316 const unsigned short int side) const; 00317 00322 std::vector<boundary_id_type> boundary_ids (const Elem* const elem, 00323 const unsigned short int side) const; 00324 00331 std::vector<boundary_id_type> raw_boundary_ids (const Elem* const elem, 00332 const unsigned short int side) const; 00333 00342 unsigned int side_with_boundary_id(const Elem* const elem, 00343 const boundary_id_type boundary_id) const; 00344 00348 void build_node_boundary_ids(std::vector<boundary_id_type> &b_ids) const; 00349 00353 void build_side_boundary_ids(std::vector<boundary_id_type> &b_ids) const; 00354 00358 std::size_t n_boundary_conds () const; 00359 00364 std::size_t n_edge_conds () const; 00365 00369 std::size_t n_nodeset_conds () const; 00370 00374 void build_node_list (std::vector<dof_id_type>& node_id_list, 00375 std::vector<boundary_id_type>& bc_id_list) const; 00376 00381 void build_node_list_from_side_list(); 00382 00387 void build_side_list_from_node_list(); 00388 00392 void build_side_list (std::vector<dof_id_type>& element_id_list, 00393 std::vector<unsigned short int>& side_list, 00394 std::vector<boundary_id_type>& bc_id_list) const; 00398 void build_active_side_list (std::vector<dof_id_type>& element_id_list, 00399 std::vector<unsigned short int>& side_list, 00400 std::vector<boundary_id_type>& bc_id_list) const; 00401 00405 void build_edge_list (std::vector<dof_id_type>& element_id_list, 00406 std::vector<unsigned short int>& edge_list, 00407 std::vector<boundary_id_type>& bc_id_list) const; 00408 00412 const std::set<boundary_id_type>& get_boundary_ids () const 00413 { return _boundary_ids; } 00414 00419 const std::set<boundary_id_type>& get_side_boundary_ids () const 00420 { return _side_boundary_ids; } 00421 00427 const std::set<boundary_id_type>& get_edge_boundary_ids () const 00428 { return _edge_boundary_ids; } 00429 00434 const std::set<boundary_id_type>& get_node_boundary_ids () const 00435 { return _node_boundary_ids; } 00436 00437 00441 void print_info (std::ostream& out=libMesh::out) const; 00442 00446 void print_summary (std::ostream& out=libMesh::out) const; 00447 00451 const std::string& get_sideset_name(boundary_id_type id) const; 00452 00457 std::string& sideset_name(boundary_id_type id); 00458 00462 const std::string& get_nodeset_name(boundary_id_type id) const; 00463 00468 std::string& nodeset_name(boundary_id_type id); 00469 00474 boundary_id_type get_id_by_name(const std::string& name) const; 00475 00479 std::map<boundary_id_type, std::string>& set_sideset_name_map () 00480 { return _ss_id_to_name; } 00481 const std::map<boundary_id_type, std::string>& get_sideset_name_map () const 00482 { return _ss_id_to_name; } 00483 00487 std::map<boundary_id_type, std::string>& set_nodeset_name_map () 00488 { return _ns_id_to_name; } 00489 const std::map<boundary_id_type, std::string>& get_nodeset_name_map () const 00490 { return _ns_id_to_name; } 00491 00496 static const boundary_id_type invalid_id; 00497 00498 00499 private: 00500 00501 00505 const MeshBase& _mesh; 00506 00511 std::multimap<const Node*, 00512 boundary_id_type> _boundary_node_id; 00513 00518 std::multimap<const Elem*, 00519 std::pair<unsigned short int, boundary_id_type> > 00520 _boundary_edge_id; 00521 00526 std::multimap<const Elem*, 00527 std::pair<unsigned short int, boundary_id_type> > 00528 _boundary_side_id; 00529 00535 std::set<boundary_id_type> _boundary_ids; 00536 00541 std::set<boundary_id_type> _side_boundary_ids; 00542 00549 std::set<boundary_id_type> _edge_boundary_ids; 00550 00555 std::set<boundary_id_type> _node_boundary_ids; 00556 00562 std::map<boundary_id_type, std::string> _ss_id_to_name; 00563 00569 std::map<boundary_id_type, std::string> _ns_id_to_name; 00570 00571 00572 // /** 00573 // * Functor class for printing a single node's info 00574 // * To be used with "for_each". 00575 // */ 00576 // class PrintNodeInfo 00577 // { 00578 // public: 00579 // inline 00580 // void operator() (const std::pair<const Node*, short int>& np) const 00581 // { 00582 // libMesh::out << " (" << np.first->id() 00583 // << ", " << np.second 00584 // << ")" << std::endl; 00585 // } 00586 // }; 00587 00588 00589 // /** 00590 // * Functor class for printing a single side's info. 00591 // * To be used with "for_each". 00592 // */ 00593 // class PrintSideInfo 00594 // { 00595 // public: 00596 // PrintSideInfo() {} 00597 // inline 00598 // void operator() (const std::pair<const Elem*, std::pair<unsigned short int,short int> >& sp) const 00599 // { 00600 // libMesh::out << " (" << sp.first->id() 00601 // << ", " << sp.second.first 00602 // << ", " << sp.second.second 00603 // << ")" << std::endl; 00604 // } 00605 // }; 00606 00607 00608 00616 class Fill 00617 { 00618 public: 00619 Fill(std::map<boundary_id_type, dof_id_type>& im) : id_map(im), cnt(0) {} 00620 00621 ~Fill() 00622 { 00623 id_map[invalid_id] = cnt; 00624 } 00625 00626 inline 00627 void operator() (const boundary_id_type& pos) 00628 { 00629 id_map[pos] = cnt++; 00630 } 00631 00632 private: 00633 std::map<boundary_id_type, dof_id_type>& id_map; 00634 dof_id_type cnt; 00635 }; 00636 00637 }; 00638 00639 00640 00641 00642 00643 00644 // ------------------------------------------------------------ 00645 // BoundaryInfo inline methods 00646 inline 00647 void BoundaryInfo::remove (const Node* node) 00648 { 00649 libmesh_assert(node); 00650 00651 // Erase everything associated with node 00652 _boundary_node_id.erase (node); 00653 } 00654 00655 00656 00657 inline 00658 void BoundaryInfo::remove (const Elem* elem) 00659 { 00660 libmesh_assert(elem); 00661 00662 // Erase everything associated with elem 00663 _boundary_edge_id.erase (elem); 00664 _boundary_side_id.erase (elem); 00665 } 00666 00667 } // namespace libMesh 00668 00669 #endif // LIBMESH_BOUNDARY_INFO_H