boundary_info.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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_BOUNDARY_INFO_H
21 #define LIBMESH_BOUNDARY_INFO_H
22 
23 // Local includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/id_types.h"
27 
28 // C++ includes
29 #include <cstddef>
30 #include <map>
31 #include <set>
32 #include <vector>
33 #include <tuple>
34 
35 namespace libMesh
36 {
37 
38 
39 // Forward declarations
40 class Elem;
41 class Node;
42 class MeshBase;
43 class UnstructuredMesh;
44 
45 
58 {
59 protected:
60  friend class MeshBase;
61 
68  BoundaryInfo (MeshBase & m);
69 
70 public:
76  BoundaryInfo & operator=(const BoundaryInfo & other_boundary_info);
77 
78 
82  ~BoundaryInfo ();
83 
88  void clear ();
89 
97  void regenerate_id_sets ();
98 
99 
107  void sync (UnstructuredMesh & boundary_mesh);
108 
120  void sync (const std::set<boundary_id_type> & requested_boundary_ids,
121  UnstructuredMesh & boundary_mesh);
122 
133  void sync (const std::set<boundary_id_type> & requested_boundary_ids,
134  UnstructuredMesh & boundary_mesh,
135  const std::set<subdomain_id_type> & subdomains_relative_to);
136 
148  void get_side_and_node_maps (UnstructuredMesh & boundary_mesh,
149  std::map<dof_id_type, dof_id_type> & node_id_map,
150  std::map<dof_id_type, unsigned char> & side_id_map,
151  Real tolerance=1.e-6);
152 
163  void add_elements (const std::set<boundary_id_type> & requested_boundary_ids,
164  UnstructuredMesh & boundary_mesh);
165 
172  void add_elements(const std::set<boundary_id_type> & requested_boundary_ids,
173  UnstructuredMesh & boundary_mesh,
174  const std::set<subdomain_id_type> & subdomains_relative_to);
175 
180  void add_node (const Node * node,
181  const boundary_id_type id);
182 
187  void add_node (const dof_id_type node,
188  const boundary_id_type id);
189 
194  void add_node (const Node * node,
195  const std::vector<boundary_id_type> & ids);
196 
201 
207  void add_edge (const dof_id_type elem,
208  const unsigned short int edge,
209  const boundary_id_type id);
210 
216  void add_edge (const Elem * elem,
217  const unsigned short int edge,
218  const boundary_id_type id);
219 
225  void add_edge (const Elem * elem,
226  const unsigned short int edge,
227  const std::vector<boundary_id_type> & ids);
228 
234  void add_shellface (const dof_id_type elem,
235  const unsigned short int shellface,
236  const boundary_id_type id);
237 
243  void add_shellface (const Elem * elem,
244  const unsigned short int shellface,
245  const boundary_id_type id);
246 
252  void add_shellface (const Elem * elem,
253  const unsigned short int shellface,
254  const std::vector<boundary_id_type> & ids);
255 
260  void add_side (const dof_id_type elem,
261  const unsigned short int side,
262  const boundary_id_type id);
263 
268  void add_side (const Elem * elem,
269  const unsigned short int side,
270  const boundary_id_type id);
271 
276  void add_side (const Elem * elem,
277  const unsigned short int side,
278  const std::vector<boundary_id_type> & ids);
279 
284  void remove (const Node * node);
285 
290  void remove (const Elem * elem);
291 
296  void remove_edge (const Elem * elem,
297  const unsigned short int edge);
298 
303  void remove_edge (const Elem * elem,
304  const unsigned short int edge,
305  const boundary_id_type id);
306 
311  void remove_shellface (const Elem * elem,
312  const unsigned short int shellface);
313 
318  void remove_shellface (const Elem * elem,
319  const unsigned short int shellface,
320  const boundary_id_type id);
321 
326  void remove_side (const Elem * elem,
327  const unsigned short int side);
328 
333  void remove_side (const Elem * elem,
334  const unsigned short int side,
335  const boundary_id_type id);
336 
345  void remove_id (boundary_id_type id);
346 
354  std::size_t n_boundary_ids () const { return _boundary_ids.size(); }
355 
359  bool has_boundary_id (const Node * const node,
360  const boundary_id_type id) const;
361 
368 #ifdef LIBMESH_ENABLE_DEPRECATED
369  std::vector<boundary_id_type> boundary_ids (const Node * node) const;
370 #endif
371 
378  void boundary_ids (const Node * node,
379  std::vector<boundary_id_type> & vec_to_fill) const;
380 
384  unsigned int n_boundary_ids (const Node * node) const;
385 
392  unsigned int n_edge_boundary_ids (const Elem * const elem,
393  const unsigned short int edge) const;
394 
404 #ifdef LIBMESH_ENABLE_DEPRECATED
405  std::vector<boundary_id_type> edge_boundary_ids (const Elem * const elem,
406  const unsigned short int edge) const;
407 #endif
408 
417  void edge_boundary_ids (const Elem * const elem,
418  const unsigned short int edge,
419  std::vector<boundary_id_type> & vec_to_fill) const;
420 
433 #ifdef LIBMESH_ENABLE_DEPRECATED
434  std::vector<boundary_id_type> raw_edge_boundary_ids (const Elem * const elem,
435  const unsigned short int edge) const;
436 #endif
437 
449  void raw_edge_boundary_ids (const Elem * const elem,
450  const unsigned short int edge,
451  std::vector<boundary_id_type> & vec_to_fill) const;
452 
459  unsigned int n_shellface_boundary_ids (const Elem * const elem,
460  const unsigned short int shellface) const;
461 
468  void shellface_boundary_ids (const Elem * const elem,
469  const unsigned short int shellface,
470  std::vector<boundary_id_type> & vec_to_fill) const;
471 
481  void raw_shellface_boundary_ids (const Elem * const elem,
482  const unsigned short int shellface,
483  std::vector<boundary_id_type> & vec_to_fill) const;
484 
489  bool has_boundary_id (const Elem * const elem,
490  const unsigned short int side,
491  const boundary_id_type id) const;
492 
506 #ifdef LIBMESH_ENABLE_DEPRECATED
507  boundary_id_type boundary_id (const Elem * const elem,
508  const unsigned short int side) const;
509 #endif
510 
515  unsigned int n_boundary_ids (const Elem * const elem,
516  const unsigned short int side) const;
517 
525 #ifdef LIBMESH_ENABLE_DEPRECATED
526  std::vector<boundary_id_type> boundary_ids (const Elem * const elem,
527  const unsigned short int side) const;
528 #endif
529 
536  void boundary_ids (const Elem * const elem,
537  const unsigned short int side,
538  std::vector<boundary_id_type> & vec_to_fill) const;
539 
550 #ifdef LIBMESH_ENABLE_DEPRECATED
551  std::vector<boundary_id_type> raw_boundary_ids (const Elem * const elem,
552  const unsigned short int side) const;
553 #endif
554 
564  void raw_boundary_ids (const Elem * const elem,
565  const unsigned short int side,
566  std::vector<boundary_id_type> & vec_to_fill) const;
567 
568  /*
569  * Copy boundary ids associated with old_elem (but not its nodes)
570  * from old_boundary_info (which may be this) into this boundary
571  * info, associating them with new_elem.
572  */
573  void copy_boundary_ids (const BoundaryInfo & old_boundary_info,
574  const Elem * const old_elem,
575  const Elem * const new_elem);
576 
584  unsigned int side_with_boundary_id(const Elem * const elem,
585  const boundary_id_type boundary_id) const;
586 
593  void build_node_boundary_ids(std::vector<boundary_id_type> & b_ids) const;
594 
601  void build_side_boundary_ids(std::vector<boundary_id_type> & b_ids) const;
602 
609  void build_shellface_boundary_ids(std::vector<boundary_id_type> & b_ids) const;
610 
616  std::size_t n_boundary_conds () const;
617 
624  std::size_t n_edge_conds () const;
625 
632  std::size_t n_shellface_conds () const;
633 
639  std::size_t n_nodeset_conds () const;
640 
650 #ifdef LIBMESH_ENABLE_DEPRECATED
651  void build_node_list (std::vector<dof_id_type> & node_id_list,
652  std::vector<boundary_id_type> & bc_id_list) const;
653 #endif
654 
662  std::vector<std::tuple<dof_id_type, boundary_id_type>>
663  build_node_list() const;
664 
670 
676 
687 #ifdef LIBMESH_ENABLE_DEPRECATED
688  void build_side_list (std::vector<dof_id_type> & element_id_list,
689  std::vector<unsigned short int> & side_list,
690  std::vector<boundary_id_type> & bc_id_list) const;
691 #endif
692 
698  std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>>
699  build_side_list() const;
700 
711 #ifdef LIBMESH_ENABLE_DEPRECATED
712  void build_active_side_list (std::vector<dof_id_type> & element_id_list,
713  std::vector<unsigned short int> & side_list,
714  std::vector<boundary_id_type> & bc_id_list) const;
715 #endif
716 
722  std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>>
723  build_active_side_list () const;
724 
735 #ifdef LIBMESH_ENABLE_DEPRECATED
736  void build_edge_list (std::vector<dof_id_type> & element_id_list,
737  std::vector<unsigned short int> & edge_list,
738  std::vector<boundary_id_type> & bc_id_list) const;
739 #endif
740 
746  std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>>
747  build_edge_list() const;
748 
759 #ifdef LIBMESH_ENABLE_DEPRECATED
760  void build_shellface_list (std::vector<dof_id_type> & element_id_list,
761  std::vector<unsigned short int> & shellface_list,
762  std::vector<boundary_id_type> & bc_id_list) const;
763 #endif
764 
770  std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>>
771  build_shellface_list() const;
772 
781  const std::set<boundary_id_type> & get_boundary_ids () const
782  { return _boundary_ids; }
783 
788  const std::set<boundary_id_type> & get_side_boundary_ids () const
789  { return _side_boundary_ids; }
790 
797  const std::set<boundary_id_type> & get_edge_boundary_ids () const
798  { return _edge_boundary_ids; }
799 
806  const std::set<boundary_id_type> & get_shellface_boundary_ids () const
807  { return _shellface_boundary_ids; }
808 
813  const std::set<boundary_id_type> & get_node_boundary_ids () const
814  { return _node_boundary_ids; }
815 
816 
820  void print_info (std::ostream & out=libMesh::out) const;
821 
825  void print_summary (std::ostream & out=libMesh::out) const;
826 
830  const std::string & get_sideset_name(boundary_id_type id) const;
831 
836  std::string & sideset_name(boundary_id_type id);
837 
841  const std::string & get_nodeset_name(boundary_id_type id) const;
842 
847  std::string & nodeset_name(boundary_id_type id);
848 
853  boundary_id_type get_id_by_name(const std::string & name) const;
854 
858  std::map<boundary_id_type, std::string> & set_sideset_name_map ()
859  { return _ss_id_to_name; }
860  const std::map<boundary_id_type, std::string> & get_sideset_name_map () const
861  { return _ss_id_to_name; }
862 
866  std::map<boundary_id_type, std::string> & set_nodeset_name_map ()
867  { return _ns_id_to_name; }
868  const std::map<boundary_id_type, std::string> & get_nodeset_name_map () const
869  { return _ns_id_to_name; }
870 
876 
877 
878 private:
879 
885  void _find_id_maps (const std::set<boundary_id_type> & requested_boundary_ids,
886  dof_id_type first_free_node_id,
887  std::map<dof_id_type, dof_id_type> * node_id_map,
888  dof_id_type first_free_elem_id,
889  std::map<std::pair<dof_id_type, unsigned char>, dof_id_type> * side_id_map,
890  const std::set<subdomain_id_type> & subdomains_relative_to);
891 
896 
901  std::multimap<const Node *,
903 
908  std::multimap<const Elem *,
909  std::pair<unsigned short int, boundary_id_type>>
911 
916  std::multimap<const Elem *,
917  std::pair<unsigned short int, boundary_id_type>>
919 
924  std::multimap<const Elem *,
925  std::pair<unsigned short int, boundary_id_type>>
927 
935  std::set<boundary_id_type> _boundary_ids;
936 
944  std::set<boundary_id_type> _side_boundary_ids;
945 
953  std::set<boundary_id_type> _edge_boundary_ids;
954 
962  std::set<boundary_id_type> _node_boundary_ids;
963 
972  std::set<boundary_id_type> _shellface_boundary_ids;
973 
979  std::map<boundary_id_type, std::string> _ss_id_to_name;
980 
986  std::map<boundary_id_type, std::string> _ns_id_to_name;
987 };
988 
989 } // namespace libMesh
990 
991 #endif // LIBMESH_BOUNDARY_INFO_H
std::string name(const ElemQuality q)
Definition: elem_quality.C:42
void add_elements(const std::set< boundary_id_type > &requested_boundary_ids, UnstructuredMesh &boundary_mesh)
std::size_t n_boundary_conds() const
std::map< boundary_id_type, std::string > _ns_id_to_name
std::set< boundary_id_type > _node_boundary_ids
const std::set< boundary_id_type > & get_side_boundary_ids() const
void remove_edge(const Elem *elem, const unsigned short int edge)
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
std::string & nodeset_name(boundary_id_type id)
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
std::set< boundary_id_type > _edge_boundary_ids
void sync(UnstructuredMesh &boundary_mesh)
void build_node_list_from_side_list()
std::size_t n_edge_conds() const
std::vector< std::tuple< dof_id_type, unsigned short int, boundary_id_type > > build_edge_list() const
void remove_id(boundary_id_type id)
BoundaryInfo(MeshBase &m)
Definition: boundary_info.C:49
void remove_shellface(const Elem *elem, const unsigned short int shellface)
std::size_t n_shellface_conds() const
unsigned int n_shellface_boundary_ids(const Elem *const elem, const unsigned short int shellface) const
std::set< boundary_id_type > _boundary_ids
unsigned short int side
Definition: xdr_io.C:50
const std::map< boundary_id_type, std::string > & get_sideset_name_map() const
unsigned int side_with_boundary_id(const Elem *const elem, const boundary_id_type boundary_id) const
The base class for all geometric element types.
Definition: elem.h:100
void print_info(std::ostream &out=libMesh::out) const
std::set< boundary_id_type > _side_boundary_ids
void build_side_boundary_ids(std::vector< boundary_id_type > &b_ids) const
void shellface_boundary_ids(const Elem *const elem, const unsigned short int shellface, std::vector< boundary_id_type > &vec_to_fill) const
std::vector< boundary_id_type > raw_edge_boundary_ids(const Elem *const elem, const unsigned short int edge) const
std::multimap< const Elem *, std::pair< unsigned short int, boundary_id_type > > _boundary_side_id
Base class for Mesh.
Definition: mesh_base.h:77
std::size_t n_boundary_ids() const
std::vector< std::tuple< dof_id_type, unsigned short int, boundary_id_type > > build_active_side_list() const
std::vector< std::tuple< dof_id_type, unsigned short int, boundary_id_type > > build_shellface_list() const
const std::set< boundary_id_type > & get_node_boundary_ids() const
std::map< boundary_id_type, std::string > _ss_id_to_name
std::vector< boundary_id_type > boundary_ids(const Node *node) const
boundary_id_type get_id_by_name(const std::string &name) const
std::map< boundary_id_type, std::string > & set_sideset_name_map()
void add_node(const Node *node, const boundary_id_type id)
const std::map< boundary_id_type, std::string > & get_nodeset_name_map() const
int8_t boundary_id_type
Definition: id_types.h:51
static const boundary_id_type invalid_id
std::multimap< const Node *, boundary_id_type > _boundary_node_id
Base class for Replicated and Distributed meshes.
void build_side_list_from_node_list()
void raw_shellface_boundary_ids(const Elem *const elem, const unsigned short int shellface, std::vector< boundary_id_type > &vec_to_fill) const
Used by the Mesh to keep track of boundary nodes and elements.
Definition: boundary_info.h:57
boundary_id_type boundary_id(const Elem *const elem, const unsigned short int side) const
An object whose state is distributed along a set of processors.
const std::string & get_nodeset_name(boundary_id_type id) const
std::string & sideset_name(boundary_id_type id)
BoundaryInfo & operator=(const BoundaryInfo &other_boundary_info)
Definition: boundary_info.C:55
const std::set< boundary_id_type > & get_boundary_ids() const
std::vector< boundary_id_type > raw_boundary_ids(const Elem *const elem, const unsigned short int side) const
void build_node_boundary_ids(std::vector< boundary_id_type > &b_ids) const
void print_summary(std::ostream &out=libMesh::out) const
void remove_side(const Elem *elem, const unsigned short int side)
std::vector< std::tuple< dof_id_type, unsigned short int, boundary_id_type > > build_side_list() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int n_edge_boundary_ids(const Elem *const elem, const unsigned short int edge) const
void copy_boundary_ids(const BoundaryInfo &old_boundary_info, const Elem *const old_elem, const Elem *const new_elem)
std::map< boundary_id_type, std::string > & set_nodeset_name_map()
const std::set< boundary_id_type > & get_edge_boundary_ids() const
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
const std::string & get_sideset_name(boundary_id_type id) const
void add_shellface(const dof_id_type elem, const unsigned short int shellface, const boundary_id_type id)
std::vector< std::tuple< dof_id_type, boundary_id_type > > build_node_list() const
std::size_t n_nodeset_conds() const
const std::set< boundary_id_type > & get_shellface_boundary_ids() const
std::set< boundary_id_type > _shellface_boundary_ids
void _find_id_maps(const std::set< boundary_id_type > &requested_boundary_ids, dof_id_type first_free_node_id, std::map< dof_id_type, dof_id_type > *node_id_map, dof_id_type first_free_elem_id, std::map< std::pair< dof_id_type, unsigned char >, dof_id_type > *side_id_map, const std::set< subdomain_id_type > &subdomains_relative_to)
std::multimap< const Elem *, std::pair< unsigned short int, boundary_id_type > > _boundary_shellface_id
OStreamProxy out(std::cout)
void build_shellface_boundary_ids(std::vector< boundary_id_type > &b_ids) const
std::multimap< const Elem *, std::pair< unsigned short int, boundary_id_type > > _boundary_edge_id
void get_side_and_node_maps(UnstructuredMesh &boundary_mesh, std::map< dof_id_type, dof_id_type > &node_id_map, std::map< dof_id_type, unsigned char > &side_id_map, Real tolerance=1.e-6)
uint8_t dof_id_type
Definition: id_types.h:64
void add_edge(const dof_id_type elem, const unsigned short int edge, const boundary_id_type id)
std::vector< boundary_id_type > edge_boundary_ids(const Elem *const elem, const unsigned short int edge) const