boundary_info.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_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 00027 // C++ includes 00028 #include <cstddef> 00029 #include <map> 00030 #include <set> 00031 #include <vector> 00032 00033 namespace libMesh 00034 { 00035 00036 00037 // Forward declarations 00038 class Elem; 00039 class Node; 00040 class MeshBase; 00041 class UnstructuredMesh; 00042 class MeshData; 00043 00044 00056 //------------------------------------------------------ 00057 // BoundaryInfo class definition 00058 class BoundaryInfo 00059 { 00060 protected: 00061 friend class MeshBase; 00062 00069 BoundaryInfo (const MeshBase& m); 00070 00071 public: 00077 BoundaryInfo& operator=(const BoundaryInfo& other_boundary_info); 00078 00079 00083 ~BoundaryInfo (); 00084 00090 void clear (); 00091 00104 void sync (UnstructuredMesh& boundary_mesh, 00105 MeshData* boundary_mesh_data=NULL, 00106 MeshData* this_mesh_data=NULL); 00107 00121 void sync (const std::set<boundary_id_type> &requested_boundary_ids, 00122 UnstructuredMesh& boundary_mesh, 00123 MeshData* boundary_mesh_data=NULL, 00124 MeshData* this_mesh_data=NULL); 00125 00130 void add_node (const Node* node, 00131 const boundary_id_type id); 00132 00137 void add_node (const dof_id_type node, 00138 const boundary_id_type id); 00139 00144 void add_node (const Node* node, 00145 const std::vector<boundary_id_type>& ids); 00146 00150 void clear_boundary_node_ids(); 00151 00156 void add_side (const dof_id_type elem, 00157 const unsigned short int side, 00158 const boundary_id_type id); 00159 00164 void add_side (const Elem* elem, 00165 const unsigned short int side, 00166 const boundary_id_type id); 00167 00172 void add_side (const Elem* elem, 00173 const unsigned short int side, 00174 const std::vector<boundary_id_type>& ids); 00175 00180 void remove (const Node* node); 00181 00186 void remove (const Elem* elem); 00187 00192 void remove_side (const Elem* elem, 00193 const unsigned short int side); 00194 00199 void remove_side (const Elem* elem, 00200 const unsigned short int side, 00201 const boundary_id_type id); 00202 00206 std::size_t n_boundary_ids () const { return _boundary_ids.size(); } 00207 00211 bool has_boundary_id (const Node* const node, 00212 const boundary_id_type id) const; 00213 00217 std::vector<boundary_id_type> boundary_ids (const Node* node) const; 00218 00222 unsigned int n_boundary_ids (const Node* node) const; 00223 00228 bool has_boundary_id (const Elem* const elem, 00229 const unsigned short int side, 00230 const boundary_id_type id) const; 00231 00239 boundary_id_type boundary_id (const Elem* const elem, 00240 const unsigned short int side) const; 00241 00246 unsigned int n_boundary_ids (const Elem* const elem, 00247 const unsigned short int side) const; 00248 00253 std::vector<boundary_id_type> boundary_ids (const Elem* const elem, 00254 const unsigned short int side) const; 00255 00262 std::vector<boundary_id_type> raw_boundary_ids (const Elem* const elem, 00263 const unsigned short int side) const; 00264 00273 unsigned int side_with_boundary_id(const Elem* const elem, 00274 const boundary_id_type boundary_id) const; 00275 00279 void build_node_boundary_ids(std::vector<boundary_id_type> &b_ids); 00280 00284 void build_side_boundary_ids(std::vector<boundary_id_type> &b_ids); 00285 00289 std::size_t n_boundary_conds () const; 00290 00294 void build_node_list (std::vector<dof_id_type>& node_id_list, 00295 std::vector<boundary_id_type>& bc_id_list) const; 00296 00301 void build_node_list_from_side_list(); 00302 00307 void build_side_list_from_node_list(); 00308 00312 void build_side_list (std::vector<dof_id_type>& element_id_list, 00313 std::vector<unsigned short int>& side_list, 00314 std::vector<boundary_id_type>& bc_id_list) const; 00315 00319 const std::set<boundary_id_type>& get_boundary_ids () const 00320 { return _boundary_ids; } 00321 00326 const std::set<boundary_id_type>& get_side_boundary_ids () const 00327 { return _side_boundary_ids; } 00328 00333 const std::set<boundary_id_type>& get_node_boundary_ids () const 00334 { return _node_boundary_ids; } 00335 00336 00340 void print_info (std::ostream& out=libMesh::out) const; 00341 00345 void print_summary (std::ostream& out=libMesh::out) const; 00346 00351 std::string& sideset_name(boundary_id_type id); 00352 00357 std::string& nodeset_name(boundary_id_type id); 00358 00363 boundary_id_type get_id_by_name(const std::string& name) const; 00364 00369 static const boundary_id_type invalid_id; 00370 00371 00372 private: 00373 00374 00378 const MeshBase& _mesh; 00379 00384 std::multimap<const Node*, 00385 boundary_id_type> _boundary_node_id; 00386 00391 std::multimap<const Elem*, 00392 std::pair<unsigned short int, boundary_id_type> > 00393 _boundary_side_id; 00394 00400 std::set<boundary_id_type> _boundary_ids; 00401 00406 std::set<boundary_id_type> _side_boundary_ids; 00407 00412 std::set<boundary_id_type> _node_boundary_ids; 00413 00419 std::map<boundary_id_type, std::string> _ss_id_to_name; 00420 00426 std::map<boundary_id_type, std::string> _ns_id_to_name; 00427 00428 00429 // /** 00430 // * Functor class for printing a single node's info 00431 // * To be used with "for_each". 00432 // */ 00433 // class PrintNodeInfo 00434 // { 00435 // public: 00436 // inline 00437 // void operator() (const std::pair<const Node*, short int>& np) const 00438 // { 00439 // libMesh::out << " (" << np.first->id() 00440 // << ", " << np.second 00441 // << ")" << std::endl; 00442 // } 00443 // }; 00444 00445 00446 // /** 00447 // * Functor class for printing a single side's info. 00448 // * To be used with "for_each". 00449 // */ 00450 // class PrintSideInfo 00451 // { 00452 // public: 00453 // PrintSideInfo() {} 00454 // inline 00455 // void operator() (const std::pair<const Elem*, std::pair<unsigned short int,short int> >& sp) const 00456 // { 00457 // libMesh::out << " (" << sp.first->id() 00458 // << ", " << sp.second.first 00459 // << ", " << sp.second.second 00460 // << ")" << std::endl; 00461 // } 00462 // }; 00463 00464 00465 00473 class Fill 00474 { 00475 public: 00476 Fill(std::map<boundary_id_type, dof_id_type>& im) : id_map(im), cnt(0) {} 00477 00478 ~Fill() 00479 { 00480 id_map[invalid_id] = cnt; 00481 } 00482 00483 inline 00484 void operator() (const boundary_id_type& pos) 00485 { 00486 id_map[pos] = cnt++; 00487 } 00488 00489 private: 00490 std::map<boundary_id_type, dof_id_type>& id_map; 00491 dof_id_type cnt; 00492 }; 00493 00494 }; 00495 00496 00497 00498 00499 00500 00501 // ------------------------------------------------------------ 00502 // BoundaryInfo inline methods 00503 inline 00504 void BoundaryInfo::remove (const Node* node) 00505 { 00506 libmesh_assert(node); 00507 00508 // Erase everything associated with node 00509 _boundary_node_id.erase (node); 00510 } 00511 00512 00513 00514 inline 00515 void BoundaryInfo::remove (const Elem* elem) 00516 { 00517 libmesh_assert(elem); 00518 00519 // Erase everything associated with elem 00520 _boundary_side_id.erase (elem); 00521 } 00522 00523 } // namespace libMesh 00524 00525 #endif // LIBMESH_BOUNDARY_INFO_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:45 UTC
Hosted By: