libMesh
boundary_info.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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"
26 #include "libmesh/parallel_object.h"
27 
28 // C++ includes
29 #include <cstddef>
30 #include <map>
31 #include <set>
32 #include <vector>
33 
34 namespace libMesh
35 {
36 
37 
38 // Forward declarations
39 class Elem;
40 class Node;
41 class MeshBase;
42 class UnstructuredMesh;
43 
44 
57 {
58 protected:
59  friend class MeshBase;
60 
67  BoundaryInfo (MeshBase & m);
68 
69 public:
75  BoundaryInfo & operator=(const BoundaryInfo & other_boundary_info);
76 
77 
81  ~BoundaryInfo ();
82 
87  void clear ();
88 
96  void regenerate_id_sets ();
97 
98 
106  void sync (UnstructuredMesh & boundary_mesh);
107 
119  void sync (const std::set<boundary_id_type> & requested_boundary_ids,
120  UnstructuredMesh & boundary_mesh);
121 
132  void sync (const std::set<boundary_id_type> & requested_boundary_ids,
133  UnstructuredMesh & boundary_mesh,
134  const std::set<subdomain_id_type> & subdomains_relative_to);
135 
147  void get_side_and_node_maps (UnstructuredMesh & boundary_mesh,
148  std::map<dof_id_type, dof_id_type> & node_id_map,
149  std::map<dof_id_type, unsigned char> & side_id_map,
150  Real tolerance=1.e-6);
151 
162  void add_elements (const std::set<boundary_id_type> & requested_boundary_ids,
163  UnstructuredMesh & boundary_mesh);
164 
171  void add_elements(const std::set<boundary_id_type> & requested_boundary_ids,
172  UnstructuredMesh & boundary_mesh,
173  const std::set<subdomain_id_type> & subdomains_relative_to);
174 
179  void add_node (const Node * node,
180  const boundary_id_type id);
181 
186  void add_node (const dof_id_type node,
187  const boundary_id_type id);
188 
193  void add_node (const Node * node,
194  const std::vector<boundary_id_type> & ids);
195 
200 
206  void add_edge (const dof_id_type elem,
207  const unsigned short int edge,
208  const boundary_id_type id);
209 
215  void add_edge (const Elem * elem,
216  const unsigned short int edge,
217  const boundary_id_type id);
218 
224  void add_edge (const Elem * elem,
225  const unsigned short int edge,
226  const std::vector<boundary_id_type> & ids);
227 
233  void add_shellface (const dof_id_type elem,
234  const unsigned short int shellface,
235  const boundary_id_type id);
236 
242  void add_shellface (const Elem * elem,
243  const unsigned short int shellface,
244  const boundary_id_type id);
245 
251  void add_shellface (const Elem * elem,
252  const unsigned short int shellface,
253  const std::vector<boundary_id_type> & ids);
254 
259  void add_side (const dof_id_type elem,
260  const unsigned short int side,
261  const boundary_id_type id);
262 
267  void add_side (const Elem * elem,
268  const unsigned short int side,
269  const boundary_id_type id);
270 
275  void add_side (const Elem * elem,
276  const unsigned short int side,
277  const std::vector<boundary_id_type> & ids);
278 
283  void remove (const Node * node);
284 
289  void remove (const Elem * elem);
290 
295  void remove_edge (const Elem * elem,
296  const unsigned short int edge);
297 
302  void remove_edge (const Elem * elem,
303  const unsigned short int edge,
304  const boundary_id_type id);
305 
310  void remove_shellface (const Elem * elem,
311  const unsigned short int shellface);
312 
317  void remove_shellface (const Elem * elem,
318  const unsigned short int shellface,
319  const boundary_id_type id);
320 
325  void remove_side (const Elem * elem,
326  const unsigned short int side);
327 
332  void remove_side (const Elem * elem,
333  const unsigned short int side,
334  const boundary_id_type id);
335 
344  void remove_id (boundary_id_type id);
345 
353  std::size_t n_boundary_ids () const { return _boundary_ids.size(); }
354 
358  bool has_boundary_id (const Node * const node,
359  const boundary_id_type id) const;
360 
367 #ifdef LIBMESH_ENABLE_DEPRECATED
368  std::vector<boundary_id_type> boundary_ids (const Node * node) const;
369 #endif
370 
377  void boundary_ids (const Node * node,
378  std::vector<boundary_id_type> & vec_to_fill) const;
379 
383  unsigned int n_boundary_ids (const Node * node) const;
384 
391  unsigned int n_edge_boundary_ids (const Elem * const elem,
392  const unsigned short int edge) const;
393 
403 #ifdef LIBMESH_ENABLE_DEPRECATED
404  std::vector<boundary_id_type> edge_boundary_ids (const Elem * const elem,
405  const unsigned short int edge) const;
406 #endif
407 
416  void edge_boundary_ids (const Elem * const elem,
417  const unsigned short int edge,
418  std::vector<boundary_id_type> & vec_to_fill) const;
419 
432 #ifdef LIBMESH_ENABLE_DEPRECATED
433  std::vector<boundary_id_type> raw_edge_boundary_ids (const Elem * const elem,
434  const unsigned short int edge) const;
435 #endif
436 
448  void raw_edge_boundary_ids (const Elem * const elem,
449  const unsigned short int edge,
450  std::vector<boundary_id_type> & vec_to_fill) const;
451 
458  unsigned int n_shellface_boundary_ids (const Elem * const elem,
459  const unsigned short int shellface) const;
460 
467  void shellface_boundary_ids (const Elem * const elem,
468  const unsigned short int shellface,
469  std::vector<boundary_id_type> & vec_to_fill) const;
470 
480  void raw_shellface_boundary_ids (const Elem * const elem,
481  const unsigned short int shellface,
482  std::vector<boundary_id_type> & vec_to_fill) const;
483 
488  bool has_boundary_id (const Elem * const elem,
489  const unsigned short int side,
490  const boundary_id_type id) const;
491 
505 #ifdef LIBMESH_ENABLE_DEPRECATED
506  boundary_id_type boundary_id (const Elem * const elem,
507  const unsigned short int side) const;
508 #endif
509 
514  unsigned int n_boundary_ids (const Elem * const elem,
515  const unsigned short int side) const;
516 
524 #ifdef LIBMESH_ENABLE_DEPRECATED
525  std::vector<boundary_id_type> boundary_ids (const Elem * const elem,
526  const unsigned short int side) const;
527 #endif
528 
535  void boundary_ids (const Elem * const elem,
536  const unsigned short int side,
537  std::vector<boundary_id_type> & vec_to_fill) const;
538 
549 #ifdef LIBMESH_ENABLE_DEPRECATED
550  std::vector<boundary_id_type> raw_boundary_ids (const Elem * const elem,
551  const unsigned short int side) const;
552 #endif
553 
563  void raw_boundary_ids (const Elem * const elem,
564  const unsigned short int side,
565  std::vector<boundary_id_type> & vec_to_fill) const;
566 
567  /*
568  * Copy boundary ids associated with old_elem (but not its nodes)
569  * from old_boundary_info (which may be this) into this boundary
570  * info, associating them with new_elem.
571  */
572  void copy_boundary_ids (const BoundaryInfo & old_boundary_info,
573  const Elem * const old_elem,
574  const Elem * const new_elem);
575 
583  unsigned int side_with_boundary_id(const Elem * const elem,
584  const boundary_id_type boundary_id) const;
585 
592  void build_node_boundary_ids(std::vector<boundary_id_type> & b_ids) const;
593 
600  void build_side_boundary_ids(std::vector<boundary_id_type> & b_ids) const;
601 
608  void build_shellface_boundary_ids(std::vector<boundary_id_type> & b_ids) const;
609 
615  std::size_t n_boundary_conds () const;
616 
623  std::size_t n_edge_conds () const;
624 
631  std::size_t n_shellface_conds () const;
632 
638  std::size_t n_nodeset_conds () const;
639 
646  void build_node_list (std::vector<dof_id_type> & node_id_list,
647  std::vector<boundary_id_type> & bc_id_list) const;
648 
654 
660 
668  void build_side_list (std::vector<dof_id_type> & element_id_list,
669  std::vector<unsigned short int> & side_list,
670  std::vector<boundary_id_type> & bc_id_list) const;
678  void build_active_side_list (std::vector<dof_id_type> & element_id_list,
679  std::vector<unsigned short int> & side_list,
680  std::vector<boundary_id_type> & bc_id_list) const;
681 
689  void build_edge_list (std::vector<dof_id_type> & element_id_list,
690  std::vector<unsigned short int> & edge_list,
691  std::vector<boundary_id_type> & bc_id_list) const;
692 
700  void build_shellface_list (std::vector<dof_id_type> & element_id_list,
701  std::vector<unsigned short int> & shellface_list,
702  std::vector<boundary_id_type> & bc_id_list) const;
703 
712  const std::set<boundary_id_type> & get_boundary_ids () const
713  { return _boundary_ids; }
714 
719  const std::set<boundary_id_type> & get_side_boundary_ids () const
720  { return _side_boundary_ids; }
721 
728  const std::set<boundary_id_type> & get_edge_boundary_ids () const
729  { return _edge_boundary_ids; }
730 
737  const std::set<boundary_id_type> & get_shellface_boundary_ids () const
738  { return _shellface_boundary_ids; }
739 
744  const std::set<boundary_id_type> & get_node_boundary_ids () const
745  { return _node_boundary_ids; }
746 
747 
751  void print_info (std::ostream & out=libMesh::out) const;
752 
756  void print_summary (std::ostream & out=libMesh::out) const;
757 
761  const std::string & get_sideset_name(boundary_id_type id) const;
762 
767  std::string & sideset_name(boundary_id_type id);
768 
772  const std::string & get_nodeset_name(boundary_id_type id) const;
773 
778  std::string & nodeset_name(boundary_id_type id);
779 
784  boundary_id_type get_id_by_name(const std::string & name) const;
785 
789  std::map<boundary_id_type, std::string> & set_sideset_name_map ()
790  { return _ss_id_to_name; }
791  const std::map<boundary_id_type, std::string> & get_sideset_name_map () const
792  { return _ss_id_to_name; }
793 
797  std::map<boundary_id_type, std::string> & set_nodeset_name_map ()
798  { return _ns_id_to_name; }
799  const std::map<boundary_id_type, std::string> & get_nodeset_name_map () const
800  { return _ns_id_to_name; }
801 
807 
808 
809 private:
810 
816  void _find_id_maps (const std::set<boundary_id_type> & requested_boundary_ids,
817  dof_id_type first_free_node_id,
818  std::map<dof_id_type, dof_id_type> * node_id_map,
819  dof_id_type first_free_elem_id,
820  std::map<std::pair<dof_id_type, unsigned char>, dof_id_type> * side_id_map,
821  const std::set<subdomain_id_type> & subdomains_relative_to);
822 
827 
832  std::multimap<const Node *,
834 
838  typedef std::multimap<const Node *, boundary_id_type>::const_iterator boundary_node_iter;
839 
845  typedef std::multimap<const Node *, boundary_id_type>::iterator boundary_node_erase_iter;
846 
851  std::multimap<const Elem *,
852  std::pair<unsigned short int, boundary_id_type>>
854 
858  typedef std::multimap<const Elem *,
859  std::pair<unsigned short int, boundary_id_type>>::const_iterator boundary_edge_iter;
860 
865  std::multimap<const Elem *,
866  std::pair<unsigned short int, boundary_id_type>>
868 
872  typedef std::multimap<const Elem *,
873  std::pair<unsigned short int, boundary_id_type>>::const_iterator boundary_shellface_iter;
874 
875 
880  std::multimap<const Elem *,
881  std::pair<unsigned short int, boundary_id_type>>
883 
887  typedef std::multimap<const Elem *,
888  std::pair<unsigned short int, boundary_id_type>>::const_iterator boundary_side_iter;
889 
895  typedef std::multimap<const Elem *,
896  std::pair<unsigned short int, boundary_id_type>>::iterator erase_iter;
904  std::set<boundary_id_type> _boundary_ids;
905 
913  std::set<boundary_id_type> _side_boundary_ids;
914 
922  std::set<boundary_id_type> _edge_boundary_ids;
923 
931  std::set<boundary_id_type> _node_boundary_ids;
932 
941  std::set<boundary_id_type> _shellface_boundary_ids;
942 
948  std::map<boundary_id_type, std::string> _ss_id_to_name;
949 
955  std::map<boundary_id_type, std::string> _ns_id_to_name;
956 };
957 
958 } // namespace libMesh
959 
960 #endif // LIBMESH_BOUNDARY_INFO_H
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
std::multimap< const Elem *, std::pair< unsigned short int, boundary_id_type > >::const_iterator boundary_shellface_iter
Typedef for iterators into the _boundary_shellface_id container.
void add_elements(const std::set< boundary_id_type > &requested_boundary_ids, UnstructuredMesh &boundary_mesh)
Generates elements along the boundary of our _mesh, which use pre-existing nodes on the boundary_mesh...
std::map< boundary_id_type, std::string > _ns_id_to_name
This structure maintains the mapping of named node sets for file formats that support named blocks...
std::set< boundary_id_type > _node_boundary_ids
Set of user-specified boundary IDs for nodes only.
std::multimap< const Elem *, std::pair< unsigned short int, boundary_id_type > >::iterator erase_iter
Some older compilers don&#39;t support erasing from a map with const_iterators, so we need to use a non-c...
void remove_edge(const Elem *elem, const unsigned short int edge)
Removes all boundary conditions associated with edge edge of element elem, if any exist...
A Node is like a Point, but with more information.
Definition: node.h:52
const std::set< boundary_id_type > & get_shellface_boundary_ids() const
std::string & nodeset_name(boundary_id_type id)
std::set< boundary_id_type > _edge_boundary_ids
Set of user-specified boundary IDs for edges only.
void sync(UnstructuredMesh &boundary_mesh)
Generates boundary_mesh data structures corresponding to the mesh data structures.
void build_node_list_from_side_list()
Adds nodes with boundary ids based on the side&#39;s boundary ids they are connected to.
~BoundaryInfo()
Destructor.
void print_summary(std::ostream &out=libMesh::out) const
Prints a summary of the boundary information.
void remove_id(boundary_id_type id)
Removes all entities (nodes, sides, edges, shellfaces) with boundary id id from their respective cont...
BoundaryInfo(MeshBase &m)
Constructor.
Definition: boundary_info.C:49
std::multimap< const Node *, boundary_id_type >::iterator boundary_node_erase_iter
Some older compilers don&#39;t support erasing from a map with const_iterators, so we need to use a non-c...
void remove_shellface(const Elem *elem, const unsigned short int shellface)
Removes all boundary conditions associated with shell face shellface of element elem, if any exist.
void raw_shellface_boundary_ids(const Elem *const elem, const unsigned short int shellface, std::vector< boundary_id_type > &vec_to_fill) const
std::set< boundary_id_type > _boundary_ids
A collection of user-specified boundary ids for sides, edges, nodes, and shell faces.
unsigned short int side
Definition: xdr_io.C:49
std::multimap< const Node *, boundary_id_type >::const_iterator boundary_node_iter
Typedef for iterators into the _boundary_node_id container.
std::size_t n_edge_conds() const
boundary_id_type get_id_by_name(const std::string &name) const
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
std::set< boundary_id_type > _side_boundary_ids
Set of user-specified boundary IDs for sides only.
std::multimap< const Elem *, std::pair< unsigned short int, boundary_id_type > >::const_iterator boundary_edge_iter
Typedef for iterators into the _boundary_edge_id container.
std::size_t n_boundary_conds() const
unsigned int n_shellface_boundary_ids(const Elem *const elem, const unsigned short int shellface) const
std::multimap< const Elem *, std::pair< unsigned short int, boundary_id_type > >::const_iterator boundary_side_iter
Typedef for iterators into the _boundary_side_id container.
The libMesh namespace provides an interface to certain functionality in the library.
void build_side_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &side_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of element numbers, sides, and ids for those sides.
std::multimap< const Elem *, std::pair< unsigned short int, boundary_id_type > > _boundary_side_id
Data structure that maps sides of elements to boundary ids.
const std::map< boundary_id_type, std::string > & get_sideset_name_map() const
const std::set< boundary_id_type > & get_boundary_ids() const
This is the MeshBase class.
Definition: mesh_base.h:68
const std::string & get_nodeset_name(boundary_id_type id) const
std::map< boundary_id_type, std::string > _ss_id_to_name
This structure maintains the mapping of named side sets for file formats that support named blocks...
std::vector< boundary_id_type > boundary_ids(const Node *node) const
std::size_t n_shellface_conds() const
void clear_boundary_node_ids()
Clears all the boundary information from all of the nodes in the mesh.
std::map< boundary_id_type, std::string > & set_sideset_name_map()
void add_node(const Node *node, const boundary_id_type id)
Add Node node with boundary id id to the boundary information data structures.
unsigned int side_with_boundary_id(const Elem *const elem, const boundary_id_type boundary_id) const
int8_t boundary_id_type
Definition: id_types.h:51
void shellface_boundary_ids(const Elem *const elem, const unsigned short int shellface, std::vector< boundary_id_type > &vec_to_fill) const
void build_side_boundary_ids(std::vector< boundary_id_type > &b_ids) const
Builds the list of unique side boundary ids.
static const boundary_id_type invalid_id
Number used for internal use.
std::multimap< const Node *, boundary_id_type > _boundary_node_id
Data structure that maps nodes in the mesh to boundary ids.
const std::map< boundary_id_type, std::string > & get_nodeset_name_map() const
The UnstructuredMesh class is derived from the MeshBase class.
void build_side_list_from_node_list()
Adds sides to a sideset if every node on that side are in the same sideset.
unsigned int n_edge_boundary_ids(const Elem *const elem, const unsigned short int edge) const
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
Definition: boundary_info.h:56
const std::set< boundary_id_type > & get_edge_boundary_ids() const
boundary_id_type boundary_id(const Elem *const elem, const unsigned short int side) const
void build_node_list(std::vector< dof_id_type > &node_id_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of nodes and ids for those nodes.
This class forms the base class for all other classes that are expected to be implemented in parallel...
void regenerate_id_sets()
Clears and regenerates the cached sets of ids.
void clear()
Clears the underlying data structures and restores the object to a pristine state with no data stored...
std::string & sideset_name(boundary_id_type id)
BoundaryInfo & operator=(const BoundaryInfo &other_boundary_info)
Actual copying operation.
Definition: boundary_info.C:55
MeshBase & _mesh
The Mesh this boundary info pertains to.
void remove_side(const Elem *elem, const unsigned short int side)
Removes all boundary conditions associated with side side of element elem, if any exist...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void build_active_side_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &side_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of active element numbers, sides, and ids for those sides.
void copy_boundary_ids(const BoundaryInfo &old_boundary_info, const Elem *const old_elem, const Elem *const new_elem)
void build_edge_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &edge_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of element numbers, edges, and boundary ids for those edges.
std::size_t n_boundary_ids() const
const std::set< boundary_id_type > & get_side_boundary_ids() const
std::map< boundary_id_type, std::string > & set_nodeset_name_map()
void print_info(std::ostream &out=libMesh::out) const
Prints the boundary information data structure.
OStreamProxy out
std::vector< boundary_id_type > edge_boundary_ids(const Elem *const elem, const unsigned short int edge) const
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
const std::set< boundary_id_type > & get_node_boundary_ids() const
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure...
void add_shellface(const dof_id_type elem, const unsigned short int shellface, const boundary_id_type id)
Add shell face shellface of element number elem with boundary id id to the boundary information data ...
std::vector< boundary_id_type > raw_edge_boundary_ids(const Elem *const elem, const unsigned short int edge) const
std::size_t n_nodeset_conds() const
std::set< boundary_id_type > _shellface_boundary_ids
Set of user-specified boundary IDs for shellfaces only.
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)
Helper method for finding consistent maps of interior to boundary dof_object ids. ...
void build_shellface_boundary_ids(std::vector< boundary_id_type > &b_ids) const
Builds the list of unique shellface boundary ids.
std::multimap< const Elem *, std::pair< unsigned short int, boundary_id_type > > _boundary_shellface_id
Data structure that maps faces of shell elements to boundary ids.
const std::string & get_sideset_name(boundary_id_type id) const
void build_shellface_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &shellface_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of element numbers, shellfaces, and boundary ids for those shellfaces.
void build_node_boundary_ids(std::vector< boundary_id_type > &b_ids) const
Builds the list of unique node boundary ids.
std::vector< boundary_id_type > raw_boundary_ids(const Elem *const elem, const unsigned short int side) const
std::multimap< const Elem *, std::pair< unsigned short int, boundary_id_type > > _boundary_edge_id
Data structure that maps edges of elements to boundary ids.
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)
Suppose we have used sync to create boundary_mesh.
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)
Add edge edge of element number elem with boundary id id to the boundary information data structure...