boundary_info.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 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 
34 namespace libMesh
35 {
36 
37 
38 // Forward declarations
39 class Elem;
40 class Node;
41 class MeshBase;
42 class UnstructuredMesh;
43 class MeshData;
44 
45 
57 //------------------------------------------------------
58 // BoundaryInfo class definition
60 {
61 protected:
62  friend class MeshBase;
63 
70  BoundaryInfo (const MeshBase& m);
71 
72 public:
78  BoundaryInfo& operator=(const BoundaryInfo& other_boundary_info);
79 
80 
84  ~BoundaryInfo ();
85 
91  void clear ();
92 
105  void sync (UnstructuredMesh& boundary_mesh,
106  MeshData* boundary_mesh_data=NULL,
107  MeshData* this_mesh_data=NULL);
108 
122  void sync (const std::set<boundary_id_type> &requested_boundary_ids,
123  UnstructuredMesh& boundary_mesh,
124  MeshData* boundary_mesh_data=NULL,
125  MeshData* this_mesh_data=NULL);
126 
131  void add_node (const Node* node,
132  const boundary_id_type id);
133 
138  void add_node (const dof_id_type node,
139  const boundary_id_type id);
140 
145  void add_node (const Node* node,
146  const std::vector<boundary_id_type>& ids);
147 
152 
158  void add_edge (const dof_id_type elem,
159  const unsigned short int edge,
160  const boundary_id_type id);
161 
167  void add_edge (const Elem* elem,
168  const unsigned short int edge,
169  const boundary_id_type id);
170 
176  void add_edge (const Elem* elem,
177  const unsigned short int edge,
178  const std::vector<boundary_id_type>& ids);
179 
184  void add_side (const dof_id_type elem,
185  const unsigned short int side,
186  const boundary_id_type id);
187 
192  void add_side (const Elem* elem,
193  const unsigned short int side,
194  const boundary_id_type id);
195 
200  void add_side (const Elem* elem,
201  const unsigned short int side,
202  const std::vector<boundary_id_type>& ids);
203 
208  void remove (const Node* node);
209 
214  void remove (const Elem* elem);
215 
220  void remove_edge (const Elem* elem,
221  const unsigned short int edge);
222 
227  void remove_edge (const Elem* elem,
228  const unsigned short int edge,
229  const boundary_id_type id);
230 
235  void remove_side (const Elem* elem,
236  const unsigned short int side);
237 
242  void remove_side (const Elem* elem,
243  const unsigned short int side,
244  const boundary_id_type id);
245 
249  std::size_t n_boundary_ids () const { return _boundary_ids.size(); }
250 
254  bool has_boundary_id (const Node* const node,
255  const boundary_id_type id) const;
256 
260  std::vector<boundary_id_type> boundary_ids (const Node* node) const;
261 
265  unsigned int n_boundary_ids (const Node* node) const;
266 
272  unsigned int n_edge_boundary_ids (const Elem* const elem,
273  const unsigned short int edge) const;
274 
280  std::vector<boundary_id_type> edge_boundary_ids (const Elem* const elem,
281  const unsigned short int edge) const;
282 
290  std::vector<boundary_id_type> raw_edge_boundary_ids (const Elem* const elem,
291  const unsigned short int edge) const;
292 
297  bool has_boundary_id (const Elem* const elem,
298  const unsigned short int side,
299  const boundary_id_type id) const;
300 
308  boundary_id_type boundary_id (const Elem* const elem,
309  const unsigned short int side) const;
310 
315  unsigned int n_boundary_ids (const Elem* const elem,
316  const unsigned short int side) const;
317 
322  std::vector<boundary_id_type> boundary_ids (const Elem* const elem,
323  const unsigned short int side) const;
324 
331  std::vector<boundary_id_type> raw_boundary_ids (const Elem* const elem,
332  const unsigned short int side) const;
333 
342  unsigned int side_with_boundary_id(const Elem* const elem,
343  const boundary_id_type boundary_id) const;
344 
348  void build_node_boundary_ids(std::vector<boundary_id_type> &b_ids);
349 
353  void build_side_boundary_ids(std::vector<boundary_id_type> &b_ids);
354 
358  std::size_t n_boundary_conds () const;
359 
364  std::size_t n_edge_conds () const;
365 
369  std::size_t n_nodeset_conds () const;
370 
374  void build_node_list (std::vector<dof_id_type>& node_id_list,
375  std::vector<boundary_id_type>& bc_id_list) const;
376 
382 
388 
392  void build_side_list (std::vector<dof_id_type>& element_id_list,
393  std::vector<unsigned short int>& side_list,
394  std::vector<boundary_id_type>& bc_id_list) const;
395 
399  const std::set<boundary_id_type>& get_boundary_ids () const
400  { return _boundary_ids; }
401 
406  const std::set<boundary_id_type>& get_side_boundary_ids () const
407  { return _side_boundary_ids; }
408 
414  const std::set<boundary_id_type>& get_edge_boundary_ids () const
415  { return _edge_boundary_ids; }
416 
421  const std::set<boundary_id_type>& get_node_boundary_ids () const
422  { return _node_boundary_ids; }
423 
424 
428  void print_info (std::ostream& out=libMesh::out) const;
429 
433  void print_summary (std::ostream& out=libMesh::out) const;
434 
439  std::string& sideset_name(boundary_id_type id);
440 
445  std::string& nodeset_name(boundary_id_type id);
446 
451  boundary_id_type get_id_by_name(const std::string& name) const;
452 
456  std::map<boundary_id_type, std::string>& set_sideset_name_map ()
457  { return _ss_id_to_name; }
458  const std::map<boundary_id_type, std::string>& get_sideset_name_map () const
459  { return _ss_id_to_name; }
460 
464  std::map<boundary_id_type, std::string>& set_nodeset_name_map ()
465  { return _ns_id_to_name; }
466  const std::map<boundary_id_type, std::string>& get_nodeset_name_map () const
467  { return _ns_id_to_name; }
468 
474 
475 
476  private:
477 
478 
482  const MeshBase& _mesh;
483 
488  std::multimap<const Node*,
490 
495  std::multimap<const Elem*,
496  std::pair<unsigned short int, boundary_id_type> >
498 
503  std::multimap<const Elem*,
504  std::pair<unsigned short int, boundary_id_type> >
506 
512  std::set<boundary_id_type> _boundary_ids;
513 
518  std::set<boundary_id_type> _side_boundary_ids;
519 
526  std::set<boundary_id_type> _edge_boundary_ids;
527 
532  std::set<boundary_id_type> _node_boundary_ids;
533 
539  std::map<boundary_id_type, std::string> _ss_id_to_name;
540 
546  std::map<boundary_id_type, std::string> _ns_id_to_name;
547 
548 
549 // /**
550 // * Functor class for printing a single node's info
551 // * To be used with "for_each".
552 // */
553 // class PrintNodeInfo
554 // {
555 // public:
556 // inline
557 // void operator() (const std::pair<const Node*, short int>& np) const
558 // {
559 // libMesh::out << " (" << np.first->id()
560 // << ", " << np.second
561 // << ")" << std::endl;
562 // }
563 // };
564 
565 
566 // /**
567 // * Functor class for printing a single side's info.
568 // * To be used with "for_each".
569 // */
570 // class PrintSideInfo
571 // {
572 // public:
573 // PrintSideInfo() {}
574 // inline
575 // void operator() (const std::pair<const Elem*, std::pair<unsigned short int,short int> >& sp) const
576 // {
577 // libMesh::out << " (" << sp.first->id()
578 // << ", " << sp.second.first
579 // << ", " << sp.second.second
580 // << ")" << std::endl;
581 // }
582 // };
583 
584 
585 
593  class Fill
594  {
595  public:
596  Fill(std::map<boundary_id_type, dof_id_type>& im) : id_map(im), cnt(0) {}
597 
599  {
600  id_map[invalid_id] = cnt;
601  }
602 
603  inline
604  void operator() (const boundary_id_type& pos)
605  {
606  id_map[pos] = cnt++;
607  }
608 
609  private:
610  std::map<boundary_id_type, dof_id_type>& id_map;
612  };
613 
614 };
615 
616 
617 
618 
619 
620 
621 // ------------------------------------------------------------
622 // BoundaryInfo inline methods
623 inline
624 void BoundaryInfo::remove (const Node* node)
625 {
626  libmesh_assert(node);
627 
628  // Erase everything associated with node
629  _boundary_node_id.erase (node);
630 }
631 
632 
633 
634 inline
635 void BoundaryInfo::remove (const Elem* elem)
636 {
637  libmesh_assert(elem);
638 
639  // Erase everything associated with elem
640  _boundary_edge_id.erase (elem);
641  _boundary_side_id.erase (elem);
642 }
643 
644 } // namespace libMesh
645 
646 #endif // LIBMESH_BOUNDARY_INFO_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:04 UTC

Hosted By:
SourceForge.net Logo