libMesh
mesh_base.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_MESH_BASE_H
21 #define LIBMESH_MESH_BASE_H
22 
23 // Local Includes
24 #include "libmesh/auto_ptr.h"
25 #include "libmesh/boundary_info.h"
26 #include "libmesh/dof_object.h" // for invalid_processor_id
27 #include "libmesh/enum_elem_type.h"
28 #include "libmesh/libmesh_common.h"
29 #include "libmesh/multi_predicates.h"
30 #include "libmesh/point_locator_base.h"
31 #include "libmesh/variant_filter_iterator.h"
32 #include "libmesh/parallel_object.h"
33 #include "libmesh/simple_range.h"
34 
35 // C++ Includes
36 #include <cstddef>
37 #include <string>
38 
39 namespace libMesh
40 {
41 
42 // forward declarations
43 class Elem;
44 class GhostingFunctor;
45 class Node;
46 class Point;
47 class Partitioner;
48 
49 template <class MT>
50 class MeshInput;
51 
52 
68 class MeshBase : public ParallelObject
69 {
70 public:
71 
77  MeshBase (const Parallel::Communicator & comm_in,
78  unsigned char dim=1);
79 
80 #ifndef LIBMESH_DISABLE_COMMWORLD
81 
89 #ifdef LIBMESH_ENABLE_DEPRECATED
90  MeshBase (unsigned char dim=1);
91 #endif
92 #endif
93 
97  MeshBase (const MeshBase & other_mesh);
98 
102  virtual UniquePtr<MeshBase> clone() const = 0;
103 
107  virtual ~MeshBase ();
108 
113 
117  const BoundaryInfo & get_boundary_info() const { return *boundary_info; }
118 
123 
127  virtual void clear ();
128 
133  bool is_prepared () const
134  { return _is_prepared; }
135 
140  virtual bool is_serial () const
141  { return true; }
142 
147  virtual bool is_serial_on_zero () const
148  { return true; }
149 
155  virtual void set_distributed ()
156  { libmesh_error(); }
157 
162  virtual bool is_replicated () const
163  { return true; }
164 
169  virtual void allgather () {}
170 
175  virtual void gather_to_zero() {}
176 
182  virtual void delete_remote_elements () {}
183 
190  unsigned int mesh_dimension () const;
191 
199  void set_mesh_dimension (unsigned char d)
200  { _elem_dims.clear(); _elem_dims.insert(d); }
201 
206  const std::set<unsigned char> & elem_dimensions() const
207  { return _elem_dims; }
208 
234  unsigned int spatial_dimension () const;
235 
240  void set_spatial_dimension(unsigned char d);
241 
251  virtual dof_id_type n_nodes () const = 0;
252 
262  virtual dof_id_type parallel_n_nodes () const = 0;
263 
267  dof_id_type n_nodes_on_proc (const processor_id_type proc) const;
268 
273  { return this->n_nodes_on_proc (this->processor_id()); }
274 
280 
285  virtual dof_id_type max_node_id () const = 0;
286 
287 #ifdef LIBMESH_ENABLE_UNIQUE_ID
288 
292 
297 #endif
298 
307  virtual void reserve_nodes (const dof_id_type nn) = 0;
308 
316  virtual dof_id_type n_elem () const = 0;
317 
325  virtual dof_id_type parallel_n_elem () const = 0;
326 
331  virtual dof_id_type max_elem_id () const = 0;
332 
337 #ifdef LIBMESH_ENABLE_UNIQUE_ID
338  virtual unique_id_type parallel_max_unique_id () const = 0;
339 #endif
340 
349  virtual void reserve_elem (const dof_id_type ne) = 0;
350 
355  virtual void update_parallel_id_counts () = 0;
356 
362  virtual dof_id_type n_active_elem () const = 0;
363 
367  dof_id_type n_elem_on_proc (const processor_id_type proc) const;
368 
373  { return this->n_elem_on_proc (this->processor_id()); }
374 
380 
385 
390  { return this->n_active_elem_on_proc (this->processor_id()); }
391 
401  dof_id_type n_sub_elem () const;
402 
407 
413  virtual const Point & point (const dof_id_type i) const = 0;
414 
420  virtual const Node & node_ref (const dof_id_type i) const {
421  return *this->node_ptr(i);
422  }
423 
428  virtual Node & node_ref (const dof_id_type i) {
429  return *this->node_ptr(i);
430  }
431 
439 #ifdef LIBMESH_ENABLE_DEPRECATED
440  virtual const Node & node (const dof_id_type i) const
441  {
442  libmesh_deprecated();
443  return *this->node_ptr(i);
444  }
445 #endif
446 
453 #ifdef LIBMESH_ENABLE_DEPRECATED
454  virtual Node & node (const dof_id_type i)
455  {
456  libmesh_deprecated();
457  return *this->node_ptr(i);
458  }
459 #endif
460 
465  virtual const Node * node_ptr (const dof_id_type i) const = 0;
466 
472  virtual Node * node_ptr (const dof_id_type i) = 0;
473 
478  virtual const Node * query_node_ptr (const dof_id_type i) const = 0;
479 
484  virtual Node * query_node_ptr (const dof_id_type i) = 0;
485 
490  virtual const Elem & elem_ref (const dof_id_type i) const {
491  return *this->elem_ptr(i);
492  }
493 
499  virtual Elem & elem_ref (const dof_id_type i) {
500  return *this->elem_ptr(i);
501  }
502 
507  virtual const Elem * elem_ptr (const dof_id_type i) const = 0;
508 
514  virtual Elem * elem_ptr (const dof_id_type i) = 0;
515 
522 #ifdef LIBMESH_ENABLE_DEPRECATED
523  virtual const Elem * elem (const dof_id_type i) const
524  {
525  libmesh_deprecated();
526  return this->elem_ptr(i);
527  }
528 #endif
529 
537 #ifdef LIBMESH_ENABLE_DEPRECATED
538  virtual Elem * elem (const dof_id_type i)
539  {
540  libmesh_deprecated();
541  return this->elem_ptr(i);
542  }
543 #endif
544 
549  virtual const Elem * query_elem_ptr (const dof_id_type i) const = 0;
550 
555  virtual Elem * query_elem_ptr (const dof_id_type i) = 0;
556 
563 #ifdef LIBMESH_ENABLE_DEPRECATED
564  virtual const Elem * query_elem (const dof_id_type i) const
565  {
566  libmesh_deprecated();
567  return this->query_elem_ptr(i);
568  }
569 #endif
570 
577 #ifdef LIBMESH_ENABLE_DEPRECATED
578  virtual Elem * query_elem (const dof_id_type i)
579  {
580  libmesh_deprecated();
581  return this->query_elem_ptr(i);
582  }
583 #endif
584 
595  virtual Node * add_point (const Point & p,
597  const processor_id_type proc_id =
599 
603  virtual Node * add_node (Node * n) = 0;
604 
612  virtual Node * insert_node(Node * n) = 0;
613 
617  virtual void delete_node (Node * n) = 0;
618 
624  virtual void renumber_node (dof_id_type old_id, dof_id_type new_id) = 0;
625 
635  virtual Elem * add_elem (Elem * e) = 0;
636 
644  virtual Elem * insert_elem (Elem * e) = 0;
645 
656  virtual void delete_elem (Elem * e) = 0;
657 
663  virtual void renumber_elem (dof_id_type old_id, dof_id_type new_id) = 0;
664 
677  virtual void find_neighbors (const bool reset_remote_elements = false,
678  const bool reset_current_list = true) = 0;
679 
685  virtual void renumber_nodes_and_elements () = 0;
686 
693  virtual void fix_broken_node_and_element_numbering () = 0;
694 
695 
696 #ifdef LIBMESH_ENABLE_AMR
697 
702  virtual bool contract () = 0;
703 #endif
704 
720  void prepare_for_use (const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false);
721 
725  virtual void partition (const unsigned int n_parts);
726 
727  void partition ()
728  { this->partition(this->n_processors()); }
729 
735  virtual void redistribute () {}
736 
741  virtual void update_post_partitioning () {}
742 
751 
760 
774  void skip_partitioning(bool skip) { _skip_partitioning = skip; }
775  bool skip_partitioning() const { return _skip_partitioning; }
776 
786  void add_ghosting_functor(GhostingFunctor & ghosting_functor)
787  { _ghosting_functors.insert(&ghosting_functor); }
788 
793  void remove_ghosting_functor(GhostingFunctor & ghosting_functor);
794 
798  std::set<GhostingFunctor *>::const_iterator ghosting_functors_begin() const
799  { return _ghosting_functors.begin(); }
800 
804  std::set<GhostingFunctor *>::const_iterator ghosting_functors_end() const
805  { return _ghosting_functors.end(); }
806 
814  void subdomain_ids (std::set<subdomain_id_type> & ids) const;
815 
824 
833  unsigned int n_partitions () const
834  { return _n_parts; }
835 
840  std::string get_info () const;
841 
845  void print_info (std::ostream & os=libMesh::out) const;
846 
852  friend std::ostream & operator << (std::ostream & os, const MeshBase & m);
853 
858  virtual void read (const std::string & name,
859  void * mesh_data=libmesh_nullptr,
860  bool skip_renumber_nodes_and_elements=false,
861  bool skip_find_neighbors=false) = 0;
862  virtual void write (const std::string & name) = 0;
863 
870  virtual void all_first_order () = 0;
871 
883  virtual void all_second_order (const bool full_ordered=true) = 0;
884 
890 
898  struct element_iterator;
899  struct const_element_iterator;
900 
908  struct node_iterator;
909  struct const_node_iterator;
910 
920  unsigned int recalculate_n_partitions();
921 
928 #ifdef LIBMESH_ENABLE_DEPRECATED
929  const PointLocatorBase & point_locator () const;
930 #endif
931 
940 
944  void clear_point_locator ();
945 
951  void set_count_lower_dim_elems_in_point_locator(bool count_lower_dim_elems);
952 
957 
965  virtual void libmesh_assert_valid_parallel_ids() const {}
966 
971  std::string & subdomain_name(subdomain_id_type id);
972  const std::string & subdomain_name(subdomain_id_type id) const;
973 
978  subdomain_id_type get_id_by_name(const std::string & name) const;
979 
980  //
981  // element_iterator accessors
982  //
983 
987  virtual element_iterator elements_begin () = 0;
988  virtual element_iterator elements_end () = 0;
989  virtual const_element_iterator elements_begin () const = 0;
990  virtual const_element_iterator elements_end () const = 0;
993 
999  virtual const_element_iterator ancestor_elements_begin () const = 0;
1000  virtual const_element_iterator ancestor_elements_end () const = 0;
1001 
1007  virtual const_element_iterator subactive_elements_begin () const = 0;
1008  virtual const_element_iterator subactive_elements_end () const = 0;
1009 
1015  virtual const_element_iterator semilocal_elements_begin () const = 0;
1016  virtual const_element_iterator semilocal_elements_end () const = 0;
1017 
1023  virtual const_element_iterator facelocal_elements_begin () const = 0;
1024  virtual const_element_iterator facelocal_elements_end () const = 0;
1025 
1029  virtual element_iterator level_elements_begin (unsigned int level) = 0;
1030  virtual element_iterator level_elements_end (unsigned int level) = 0;
1031  virtual const_element_iterator level_elements_begin (unsigned int level) const = 0;
1032  virtual const_element_iterator level_elements_end (unsigned int level) const = 0;
1033 
1038  virtual element_iterator pid_elements_end (processor_id_type proc_id) = 0;
1039  virtual const_element_iterator pid_elements_begin (processor_id_type proc_id) const = 0;
1040  virtual const_element_iterator pid_elements_end (processor_id_type proc_id) const = 0;
1041 
1045  virtual element_iterator type_elements_begin (ElemType type) = 0;
1046  virtual element_iterator type_elements_end (ElemType type) = 0;
1047  virtual const_element_iterator type_elements_begin (ElemType type) const = 0;
1048  virtual const_element_iterator type_elements_end (ElemType type) const = 0;
1049 
1057 
1065 
1070  virtual element_iterator ghost_elements_begin () = 0;
1071  virtual element_iterator ghost_elements_end () = 0;
1072  virtual const_element_iterator ghost_elements_begin () const = 0;
1073  virtual const_element_iterator ghost_elements_end () const = 0;
1074 
1080  virtual element_iterator
1081  evaluable_elements_begin (const DofMap & dof_map,
1082  unsigned int var_num = libMesh::invalid_uint) = 0;
1083 
1084  virtual element_iterator
1085  evaluable_elements_end (const DofMap & dof_map,
1086  unsigned int var_num = libMesh::invalid_uint) = 0;
1087 
1088  virtual const_element_iterator
1089  evaluable_elements_begin (const DofMap & dof_map,
1090  unsigned int var_num = libMesh::invalid_uint) const = 0;
1091 
1092  virtual const_element_iterator
1093  evaluable_elements_end (const DofMap & dof_map,
1094  unsigned int var_num = libMesh::invalid_uint) const = 0;
1095 
1096 #ifdef LIBMESH_ENABLE_AMR
1097 
1100  virtual element_iterator flagged_elements_begin (unsigned char rflag) = 0;
1101  virtual element_iterator flagged_elements_end (unsigned char rflag) = 0;
1102  virtual const_element_iterator flagged_elements_begin (unsigned char rflag) const = 0;
1103  virtual const_element_iterator flagged_elements_end (unsigned char rflag) const = 0;
1104 
1109  virtual element_iterator flagged_pid_elements_begin (unsigned char rflag,
1110  processor_id_type pid) = 0;
1111  virtual element_iterator flagged_pid_elements_end (unsigned char rflag,
1112  processor_id_type pid) = 0;
1113  virtual const_element_iterator flagged_pid_elements_begin (unsigned char rflag,
1114  processor_id_type pid) const = 0;
1115  virtual const_element_iterator flagged_pid_elements_end (unsigned char rflag,
1116  processor_id_type pid) const = 0;
1117 #endif
1118 
1124  virtual element_iterator active_elements_begin () = 0;
1125  virtual element_iterator active_elements_end () = 0;
1126  virtual const_element_iterator active_elements_begin () const = 0;
1127  virtual const_element_iterator active_elements_end () const = 0;
1130 
1131  virtual element_iterator local_elements_begin () = 0;
1132  virtual element_iterator local_elements_end () = 0;
1133  virtual const_element_iterator local_elements_begin () const = 0;
1134  virtual const_element_iterator local_elements_end () const = 0;
1135 
1140 
1144  virtual const_element_iterator active_type_elements_end (ElemType type) const = 0;
1145 
1150 
1155 
1156  virtual element_iterator active_subdomain_set_elements_begin (std::set<subdomain_id_type> ss) = 0;
1157  virtual element_iterator active_subdomain_set_elements_end (std::set<subdomain_id_type> ss) = 0;
1158  virtual const_element_iterator active_subdomain_set_elements_begin (std::set<subdomain_id_type> ss) const = 0;
1159  virtual const_element_iterator active_subdomain_set_elements_end (std::set<subdomain_id_type> ss) const = 0;
1160 
1165 
1166  virtual element_iterator local_level_elements_begin (unsigned int level) = 0;
1167  virtual element_iterator local_level_elements_end (unsigned int level) = 0;
1168  virtual const_element_iterator local_level_elements_begin (unsigned int level) const = 0;
1169  virtual const_element_iterator local_level_elements_end (unsigned int level) const = 0;
1170 
1171  virtual element_iterator local_not_level_elements_begin (unsigned int level) = 0;
1172  virtual element_iterator local_not_level_elements_end (unsigned int level) = 0;
1173  virtual const_element_iterator local_not_level_elements_begin (unsigned int level) const = 0;
1174  virtual const_element_iterator local_not_level_elements_end (unsigned int level) const = 0;
1175 
1176  virtual element_iterator not_level_elements_begin (unsigned int level) = 0;
1177  virtual element_iterator not_level_elements_end (unsigned int level) = 0;
1178  virtual const_element_iterator not_level_elements_begin (unsigned int level) const = 0;
1179  virtual const_element_iterator not_level_elements_end (unsigned int level) const = 0;
1180 
1187 
1192 
1195  virtual const_element_iterator not_local_elements_begin () const = 0;
1196  virtual const_element_iterator not_local_elements_end () const = 0;
1197 
1202 
1206  virtual const_element_iterator not_active_elements_end () const = 0;
1207 
1212 
1213  //
1214  // node_iterator accessors
1215  //
1216 
1220  virtual node_iterator nodes_begin () = 0;
1221  virtual node_iterator nodes_end () = 0;
1222  virtual const_node_iterator nodes_begin () const = 0;
1223  virtual const_node_iterator nodes_end () const = 0;
1226 
1230  virtual node_iterator active_nodes_begin () = 0;
1231  virtual node_iterator active_nodes_end () = 0;
1232  virtual const_node_iterator active_nodes_begin () const = 0;
1233  virtual const_node_iterator active_nodes_end () const = 0;
1234 
1238  virtual node_iterator local_nodes_begin () = 0;
1239  virtual node_iterator local_nodes_end () = 0;
1240  virtual const_node_iterator local_nodes_begin () const = 0;
1241  virtual const_node_iterator local_nodes_end () const = 0;
1244 
1248  virtual node_iterator pid_nodes_begin (processor_id_type proc_id) = 0;
1249  virtual node_iterator pid_nodes_end (processor_id_type proc_id) = 0;
1250  virtual const_node_iterator pid_nodes_begin (processor_id_type proc_id) const = 0;
1251  virtual const_node_iterator pid_nodes_end (processor_id_type proc_id) const = 0;
1252 
1256  virtual node_iterator bid_nodes_begin (boundary_id_type bndry_id) = 0;
1257  virtual node_iterator bid_nodes_end (boundary_id_type bndry_id) = 0;
1258  virtual const_node_iterator bid_nodes_begin (boundary_id_type bndry_id) const = 0;
1259  virtual const_node_iterator bid_nodes_end (boundary_id_type bndry_id) const = 0;
1260 
1264  virtual node_iterator bnd_nodes_begin () = 0;
1265  virtual node_iterator bnd_nodes_end () = 0;
1266  virtual const_node_iterator bnd_nodes_begin () const = 0;
1267  virtual const_node_iterator bnd_nodes_end () const = 0;
1268 
1274  virtual node_iterator
1275  evaluable_nodes_begin (const DofMap & dof_map,
1276  unsigned int var_num = libMesh::invalid_uint) = 0;
1277 
1278  virtual node_iterator
1279  evaluable_nodes_end (const DofMap & dof_map,
1280  unsigned int var_num = libMesh::invalid_uint) = 0;
1281 
1282  virtual const_node_iterator
1283  evaluable_nodes_begin (const DofMap & dof_map,
1284  unsigned int var_num = libMesh::invalid_uint) const = 0;
1285 
1286  virtual const_node_iterator
1287  evaluable_nodes_end (const DofMap & dof_map,
1288  unsigned int var_num = libMesh::invalid_uint) const = 0;
1289 
1293  std::map<subdomain_id_type, std::string> & set_subdomain_name_map ()
1294  { return _block_id_to_name; }
1295  const std::map<subdomain_id_type, std::string> & get_subdomain_name_map () const
1296  { return _block_id_to_name; }
1297 
1298 
1304  void cache_elem_dims();
1305 
1310  void detect_interior_parents();
1311 
1312 
1322 
1323 
1324 protected:
1325 
1329  unsigned int & set_n_partitions ()
1330  { return _n_parts; }
1331 
1342  unsigned int _n_parts;
1343 
1348 
1357 
1363 
1371 
1372 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1373 
1377 #endif
1378 
1383 
1390 
1398 
1404  std::map<subdomain_id_type, std::string> _block_id_to_name;
1405 
1411  std::set<unsigned char> _elem_dims;
1412 
1417  unsigned char _spatial_dimension;
1418 
1425 
1433  std::set<GhostingFunctor *> _ghosting_functors;
1434 
1439  friend class Partitioner;
1440 
1445  friend class MeshInput<MeshBase>;
1446 
1451  friend class BoundaryInfo;
1452 
1453 private:
1460  MeshBase & operator= (const MeshBase & other);
1461 };
1462 
1463 
1464 
1465 
1466 
1467 
1468 
1469 
1470 
1471 
1472 
1476 struct
1477 MeshBase::element_iterator : variant_filter_iterator<MeshBase::Predicate, Elem *>
1478 {
1479  // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
1480  template <typename PredType, typename IterType>
1481  element_iterator (const IterType & d,
1482  const IterType & e,
1483  const PredType & p ) :
1485 };
1486 
1487 
1488 
1489 
1494 struct
1496  Elem * const,
1497  Elem * const &,
1498  Elem * const *>
1499 {
1503  template <typename PredType, typename IterType>
1504  const_element_iterator (const IterType & d,
1505  const IterType & e,
1506  const PredType & p ) :
1507  variant_filter_iterator<MeshBase::Predicate, Elem * const, Elem * const &, Elem * const *>(d,e,p) {}
1508 
1516  variant_filter_iterator<Predicate, Elem * const, Elem * const &, Elem * const *>(rhs) {}
1517 };
1518 
1519 
1520 
1521 
1522 
1523 
1524 
1528 struct
1529 MeshBase::node_iterator : variant_filter_iterator<MeshBase::Predicate, Node *>
1530 {
1534  template <typename PredType, typename IterType>
1535  node_iterator (const IterType & d,
1536  const IterType & e,
1537  const PredType & p ) :
1539 };
1540 
1541 
1542 
1543 
1548 struct
1550  Node * const,
1551  Node * const &,
1552  Node * const *>
1553 {
1557  template <typename PredType, typename IterType>
1558  const_node_iterator (const IterType & d,
1559  const IterType & e,
1560  const PredType & p ) :
1561  variant_filter_iterator<MeshBase::Predicate, Node * const, Node * const &, Node * const *>(d,e,p) {}
1562 
1570  variant_filter_iterator<Predicate, Node * const, Node * const &, Node * const *>(rhs) {}
1571 };
1572 
1573 
1574 } // namespace libMesh
1575 
1576 #endif // LIBMESH_MESH_BASE_H
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
The definition of the element_iterator struct.
Definition: mesh_base.h:1476
dof_id_type n_nodes_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:349
dof_id_type n_active_sub_elem() const
Same as n_sub_elem(), but only counts active elements.
Definition: mesh_base.C:399
virtual element_iterator evaluable_elements_begin(const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint)=0
Iterate over elements in the Mesh where the solution (as distributed by the given DofMap) can be eval...
virtual node_iterator active_nodes_end()=0
virtual unique_id_type parallel_max_unique_id() const =0
virtual element_iterator ancestor_elements_begin()=0
Iterate over elements for which elem->ancestor() is true.
virtual void redistribute()
Redistribute elements between processors.
Definition: mesh_base.h:735
The SimpleRange templated class is intended to make it easy to construct ranges from pairs of iterato...
Definition: simple_range.h:36
virtual bool is_serial_on_zero() const
Definition: mesh_base.h:147
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:117
virtual element_iterator facelocal_elements_end()=0
virtual void reserve_nodes(const dof_id_type nn)=0
Reserves space for a known number of nodes.
virtual element_iterator not_ancestor_elements_begin()=0
bool _skip_renumber_nodes_and_elements
If this is true then renumbering will be kept to a minimum.
Definition: mesh_base.h:1389
UniquePtr< PointLocatorBase > _point_locator
A PointLocator class for this mesh.
Definition: mesh_base.h:1356
virtual void libmesh_assert_valid_parallel_ids() const
Verify id and processor_id consistency of our elements and nodes containers.
Definition: mesh_base.h:965
A Node is like a Point, but with more information.
Definition: node.h:52
Encapsulates the MPI_Comm object.
Definition: parallel.h:657
virtual dof_id_type n_active_elem() const =0
This abstract base class defines the interface by which library code and user code can report associa...
virtual void renumber_node(dof_id_type old_id, dof_id_type new_id)=0
Changes the id of node old_id, both by changing node(old_id)->id() and by moving node(old_id) in the ...
virtual element_iterator not_level_elements_begin(unsigned int level)=0
variant_filter_iterator(const IterType &d, const IterType &e, const PredType &p)
Templated Constructor.
virtual element_iterator active_subdomain_set_elements_end(std::set< subdomain_id_type > ss)=0
virtual bool is_serial() const
Definition: mesh_base.h:140
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value.
Definition: libmesh.h:184
virtual element_iterator not_local_elements_end()=0
virtual const Point & point(const dof_id_type i) const =0
virtual SimpleRange< node_iterator > local_node_ptr_range()=0
virtual node_iterator pid_nodes_end(processor_id_type proc_id)=0
UniquePtr< BoundaryInfo > boundary_info
This class holds the boundary information.
Definition: mesh_base.h:1321
virtual element_iterator level_elements_begin(unsigned int level)=0
Iterate over elements of a given level.
BoundaryInfo & get_boundary_info()
Writable information about boundary ids on the mesh.
Definition: mesh_base.h:122
bool _skip_partitioning
If this is true then no partitioning should be done.
Definition: mesh_base.h:1382
virtual node_iterator evaluable_nodes_end(const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint)=0
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use...
Definition: mesh_base.h:749
bool skip_partitioning() const
Definition: mesh_base.h:775
void detect_interior_parents()
Search the mesh for elements that have a neighboring element of dim+1 and set that element as the int...
Definition: mesh_base.C:678
virtual element_iterator local_level_elements_end(unsigned int level)=0
void skip_partitioning(bool skip)
If true is passed in then this mesh will no longer be (re)partitioned.
Definition: mesh_base.h:774
virtual element_iterator active_semilocal_elements_end()=0
The definition of the const_element_iterator struct.
Definition: mesh_base.h:1494
unsigned int dim
virtual bool is_replicated() const
Definition: mesh_base.h:162
virtual element_iterator active_subdomain_elements_end(subdomain_id_type subdomain_id)=0
dof_id_type n_local_nodes() const
Definition: mesh_base.h:272
virtual element_iterator not_ancestor_elements_end()=0
unsigned int n_partitions() const
Definition: mesh_base.h:833
virtual node_iterator bid_nodes_end(boundary_id_type bndry_id)=0
virtual element_iterator local_elements_begin()=0
Predicates::multi_predicate Predicate
We need an empty, generic class to act as a predicate for this and derived mesh classes.
Definition: mesh_base.h:889
virtual void allgather()
Gathers all elements and nodes of the mesh onto every processor.
Definition: mesh_base.h:169
virtual const Node & node_ref(const dof_id_type i) const
Definition: mesh_base.h:420
ElemType
Defines an enum for geometric element types.
virtual element_iterator unpartitioned_elements_begin()=0
Iterate over unpartitioned elements in the Mesh.
void set_spatial_dimension(unsigned char d)
Sets the "spatial dimension" of the Mesh.
Definition: mesh_base.C:164
dof_id_type n_unpartitioned_elem() const
Definition: mesh_base.h:378
virtual element_iterator not_subactive_elements_begin()=0
processor_id_type n_processors() const
virtual dof_id_type max_node_id() const =0
void remove_ghosting_functor(GhostingFunctor &ghosting_functor)
Removes a functor which was previously added to the set of ghosting functors.
Definition: mesh_base.C:305
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
virtual element_iterator ancestor_elements_end()=0
uint8_t processor_id_type
Definition: id_types.h:99
virtual element_iterator flagged_elements_end(unsigned char rflag)=0
virtual void gather_to_zero()
Gathers all elements and nodes of the mesh onto processor zero.
Definition: mesh_base.h:175
const class libmesh_nullptr_t libmesh_nullptr
virtual const Node * node_ptr(const dof_id_type i) const =0
virtual Elem & elem_ref(const dof_id_type i)
Definition: mesh_base.h:499
const_element_iterator(const IterType &d, const IterType &e, const PredType &p)
Templated forwarding ctor – forwards to appropriate variant_filter_iterator ctor.
Definition: mesh_base.h:1504
virtual const Elem * elem(const dof_id_type i) const
Definition: mesh_base.h:523
virtual node_iterator bid_nodes_begin(boundary_id_type bndry_id)=0
Iterate over nodes for which BoundaryInfo::has_boundary_id(node, bndry_id) is true.
virtual void fix_broken_node_and_element_numbering()=0
There is no reason for a user to ever call this function.
UniquePtr< Partitioner > _partitioner
A partitioner to use at each prepare_for_use().
Definition: mesh_base.h:1370
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
unsigned char _spatial_dimension
The "spatial dimension" of the Mesh.
Definition: mesh_base.h:1417
virtual element_iterator flagged_pid_elements_end(unsigned char rflag, processor_id_type pid)=0
virtual element_iterator subactive_elements_end()=0
virtual Elem * elem(const dof_id_type i)
Definition: mesh_base.h:538
bool _allow_remote_element_removal
If this is false then even on DistributedMesh remote elements will not be deleted during mesh prepara...
Definition: mesh_base.h:1397
The libMesh namespace provides an interface to certain functionality in the library.
virtual const Elem * query_elem(const dof_id_type i) const
Definition: mesh_base.h:564
virtual void all_first_order()=0
Converts a mesh with higher-order elements into a mesh with linear elements.
virtual Elem * query_elem(const dof_id_type i)
Definition: mesh_base.h:578
virtual element_iterator not_active_elements_end()=0
std::string get_info() const
Definition: mesh_base.C:414
virtual element_iterator active_local_subdomain_elements_end(subdomain_id_type subdomain_id)=0
virtual Node & node_ref(const dof_id_type i)
Definition: mesh_base.h:428
virtual element_iterator active_semilocal_elements_begin()=0
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
virtual element_iterator local_level_elements_begin(unsigned int level)=0
This is the MeshBase class.
Definition: mesh_base.h:68
The Partitioner class provides a uniform interface for partitioning algorithms.
Definition: partitioner.h:48
std::set< GhostingFunctor * >::const_iterator ghosting_functors_end() const
End of range of ghosting functors.
Definition: mesh_base.h:804
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
const PointLocatorBase & point_locator() const
Definition: mesh_base.C:517
virtual void set_distributed()
Asserts that not all elements and nodes of the mesh necessarily exist on the current processor...
Definition: mesh_base.h:155
node_iterator(const IterType &d, const IterType &e, const PredType &p)
Templated forwarding ctor – forwards to appropriate variant_filter_iterator ctor.
Definition: mesh_base.h:1535
virtual node_iterator nodes_begin()=0
Iterate over all the nodes in the Mesh.
virtual element_iterator elements_begin()=0
Iterate over all the elements in the Mesh.
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=0
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:167
virtual element_iterator level_elements_end(unsigned int level)=0
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:1433
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition: mesh_base.h:1376
virtual element_iterator facelocal_elements_begin()=0
Iterate over elements which are on or have a neighbor on the current processor.
unsigned int _n_parts
The number of partitions the mesh has.
Definition: mesh_base.h:1342
virtual element_iterator ghost_elements_end()=0
virtual element_iterator active_subdomain_elements_begin(subdomain_id_type subdomain_id)=0
virtual element_iterator active_subdomain_set_elements_begin(std::set< subdomain_id_type > ss)=0
virtual node_iterator evaluable_nodes_begin(const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint)=0
Iterate over nodes in the Mesh where the solution (as distributed by the given DofMap) can be evaluat...
virtual dof_id_type max_elem_id() const =0
void allow_remote_element_removal(bool allow)
If false is passed in then this mesh will no longer have remote elements deleted when being prepared ...
Definition: mesh_base.h:758
virtual element_iterator active_local_subdomain_elements_begin(subdomain_id_type subdomain_id)=0
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true)=0
Locate element face (edge in 2D) neighbors.
virtual element_iterator not_subactive_elements_end()=0
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
Definition: mesh_base.h:1295
virtual node_iterator active_nodes_begin()=0
Iterate over only the active nodes in the Mesh.
int8_t boundary_id_type
Definition: id_types.h:51
virtual void delete_elem(Elem *e)=0
Removes element e from the mesh.
virtual SimpleRange< element_iterator > element_ptr_range()=0
dof_id_type n_elem_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:362
virtual element_iterator semilocal_elements_begin()=0
Iterate over elements for which elem->is_semilocal() is true for the current processor.
virtual node_iterator local_nodes_end()=0
This class defines an abstract interface for Mesh input.
Definition: mesh_base.h:50
void subdomain_ids(std::set< subdomain_id_type > &ids) const
Constructs a list of all subdomain identifiers in the global mesh.
Definition: mesh_base.C:315
virtual void all_second_order(const bool full_ordered=true)=0
Converts a (conforming, non-refined) mesh with linear elements into a mesh with second-order elements...
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:335
virtual element_iterator active_local_elements_begin()=0
virtual element_iterator active_pid_elements_begin(processor_id_type proc_id)=0
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
virtual element_iterator type_elements_end(ElemType type)=0
virtual void update_parallel_id_counts()=0
Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors...
virtual element_iterator flagged_elements_begin(unsigned char rflag)=0
Iterate over all elements with a specified refinement flag.
virtual element_iterator elements_end()=0
virtual dof_id_type parallel_n_elem() const =0
virtual element_iterator not_active_elements_begin()=0
virtual SimpleRange< node_iterator > node_ptr_range()=0
virtual const Node * query_node_ptr(const dof_id_type i) const =0
void clear_point_locator()
Releases the current PointLocator object.
Definition: mesh_base.C:555
virtual Node * insert_node(Node *n)=0
Insert Node n into the Mesh at a location consistent with n->id(), allocating extra storage if necess...
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
Definition: boundary_info.h:56
virtual element_iterator local_elements_end()=0
virtual element_iterator active_unpartitioned_elements_end()=0
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:324
dof_id_type n_unpartitioned_nodes() const
Definition: mesh_base.h:278
virtual void delete_node(Node *n)=0
Removes the Node n from the mesh.
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1411
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Prepare a newly created (or read) mesh for use.
Definition: mesh_base.C:174
unsigned int spatial_dimension() const
Definition: mesh_base.C:157
std::string & subdomain_name(subdomain_id_type id)
Definition: mesh_base.C:576
This is the base class for point locators.
virtual void write(const std::string &name)=0
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
Definition: mesh_base.h:199
bool is_prepared() const
Definition: mesh_base.h:133
const std::set< unsigned char > & elem_dimensions() const
Definition: mesh_base.h:206
std::map< subdomain_id_type, std::string > & set_subdomain_name_map()
Definition: mesh_base.h:1293
virtual element_iterator not_level_elements_end(unsigned int level)=0
This class forms the base class for all other classes that are expected to be implemented in parallel...
subdomain_id_type get_id_by_name(const std::string &name) const
Definition: mesh_base.C:596
virtual void clear()
Deletes all the data that are currently stored.
Definition: mesh_base.C:285
virtual node_iterator bnd_nodes_end()=0
friend std::ostream & operator<<(std::ostream &os, const MeshBase &m)
Equivalent to calling print_info() above, but now you can write: Mesh mesh; libMesh::out << mesh << s...
Definition: mesh_base.C:455
virtual element_iterator active_elements_begin()=0
Active, local, and negation forms of the element iterators described above.
virtual element_iterator flagged_pid_elements_begin(unsigned char rflag, processor_id_type pid)=0
Iterate over all elements with a specified refinement flag on a specified processor.
virtual dof_id_type parallel_n_nodes() const =0
dof_id_type n_active_local_elem() const
Definition: mesh_base.h:389
UniquePtr< GhostingFunctor > _default_ghosting
The default geometric GhostingFunctor, used to implement standard libMesh element ghosting behavior...
Definition: mesh_base.h:1424
virtual Node * add_node(Node *n)=0
Add Node n to the end of the vertex array.
virtual element_iterator pid_elements_begin(processor_id_type proc_id)=0
Iterate over all elements with a specified processor id.
virtual element_iterator active_elements_end()=0
The definition of the node_iterator struct.
Definition: mesh_base.h:1528
const_node_iterator(const IterType &d, const IterType &e, const PredType &p)
Templated forwarding ctor – forwards to appropriate variant_filter_iterator ctor.
Definition: mesh_base.h:1558
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:490
virtual Elem * insert_elem(Elem *e)=0
Insert elem e to the element array, preserving its id and replacing/deleting any existing element wit...
virtual node_iterator local_nodes_begin()=0
Iterate over local nodes (nodes whose processor_id() matches the current processor).
virtual element_iterator active_not_local_elements_end()=0
unsigned int recalculate_n_partitions()
In a few (very rare) cases, the user may have manually tagged the elements with specific processor ID...
Definition: mesh_base.C:493
dof_id_type n_local_elem() const
Definition: mesh_base.h:372
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
std::set< GhostingFunctor * >::const_iterator ghosting_functors_begin() const
Beginning of range of ghosting functors.
Definition: mesh_base.h:798
virtual node_iterator nodes_end()=0
virtual element_iterator active_pid_elements_end(processor_id_type proc_id)=0
virtual bool contract()=0
Delete subactive (i.e.
virtual element_iterator active_unpartitioned_elements_begin()=0
Iterate over active unpartitioned elements in the Mesh.
virtual UniquePtr< Partitioner > & partitioner()
A partitioner to use at each prepare_for_use()
Definition: mesh_base.h:112
virtual void renumber_elem(dof_id_type old_id, dof_id_type new_id)=0
Changes the id of element old_id, both by changing elem(old_id)->id() and by moving elem(old_id) in t...
bool get_count_lower_dim_elems_in_point_locator() const
Get the current value of _count_lower_dim_elems_in_point_locator.
Definition: mesh_base.C:569
virtual element_iterator type_elements_begin(ElemType type)=0
Iterate over all elements with a specified geometric type.
element_iterator(const IterType &d, const IterType &e, const PredType &p)
Definition: mesh_base.h:1481
virtual node_iterator bnd_nodes_begin()=0
Iterate over nodes for which BoundaryInfo::n_boundary_ids(node) > 0.
OStreamProxy out
virtual element_iterator evaluable_elements_end(const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint)=0
virtual element_iterator semilocal_elements_end()=0
unsigned int mesh_dimension() const
Definition: mesh_base.C:148
bool allow_renumbering() const
Definition: mesh_base.h:750
bool _is_prepared
Flag indicating if the mesh has been prepared for use.
Definition: mesh_base.h:1347
void set_count_lower_dim_elems_in_point_locator(bool count_lower_dim_elems)
In the point locator, do we count lower dimensional elements when we refine point locator regions...
Definition: mesh_base.C:562
The definition of the const_node_iterator struct.
Definition: mesh_base.h:1548
MeshBase(const Parallel::Communicator &comm_in, unsigned char dim=1)
Constructor.
Definition: mesh_base.C:49
virtual ~MeshBase()
Destructor.
Definition: mesh_base.C:139
virtual const Node & node(const dof_id_type i) const
Definition: mesh_base.h:440
virtual element_iterator unpartitioned_elements_end()=0
unique_id_type next_unique_id()
Definition: mesh_base.h:291
dof_id_type n_sub_elem() const
Definition: mesh_base.C:384
virtual element_iterator active_not_local_elements_begin()=0
virtual Node & node(const dof_id_type i)
Definition: mesh_base.h:454
const_node_iterator(const MeshBase::node_iterator &rhs)
The conversion-to-const ctor.
Definition: mesh_base.h:1569
void set_next_unique_id(unique_id_type id)
Sets the next unique id to be used.
Definition: mesh_base.h:296
virtual element_iterator not_local_elements_begin()=0
void cache_elem_dims()
Search the mesh and cache the different dimensions of the elements present in the mesh...
Definition: mesh_base.C:612
virtual void delete_remote_elements()
When supported, deletes all nonlocal elements of the mesh except for "ghosts" which touch a local ele...
Definition: mesh_base.h:182
const_element_iterator(const MeshBase::element_iterator &rhs)
The conversion-to-const ctor.
Definition: mesh_base.h:1515
virtual void update_post_partitioning()
Recalculate any cached data after elements and nodes have been repartitioned.
Definition: mesh_base.h:741
subdomain_id_type n_subdomains() const
Definition: mesh_base.C:334
virtual element_iterator active_type_elements_end(ElemType type)=0
virtual dof_id_type n_nodes() const =0
virtual const Elem * elem_ptr(const dof_id_type i) const =0
virtual dof_id_type n_elem() const =0
virtual element_iterator local_not_level_elements_end(unsigned int level)=0
virtual void read(const std::string &name, void *mesh_data=libmesh_nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false)=0
Interfaces for reading/writing a mesh to/from a file.
virtual UniquePtr< MeshBase > clone() const =0
Virtual "copy constructor".
bool allow_remote_element_removal() const
Definition: mesh_base.h:759
virtual node_iterator pid_nodes_begin(processor_id_type proc_id)=0
Iterate over nodes with processor_id() == proc_id.
virtual element_iterator active_local_elements_end()=0
bool _count_lower_dim_elems_in_point_locator
Do we count lower dimensional elements in point locator refinement? This is relevant in tree-based po...
Definition: mesh_base.h:1362
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
virtual void reserve_elem(const dof_id_type ne)=0
Reserves space for a known number of elements.
void print_info(std::ostream &os=libMesh::out) const
Prints relevant information about the mesh.
Definition: mesh_base.C:448
uint8_t unique_id_type
Definition: id_types.h:79
virtual element_iterator ghost_elements_begin()=0
Iterate over "ghost" elements in the Mesh.
UniquePtr< PointLocatorBase > sub_point_locator() const
Definition: mesh_base.C:534
std::map< subdomain_id_type, std::string > _block_id_to_name
This structure maintains the mapping of named blocks for file formats that support named blocks...
Definition: mesh_base.h:1404
unsigned int & set_n_partitions()
Definition: mesh_base.h:1329
virtual element_iterator subactive_elements_begin()=0
Iterate over elements for which elem->subactive() is true.
virtual void renumber_nodes_and_elements()=0
After partitioning a mesh it is useful to renumber the nodes and elements so that they lie in contigu...
dof_id_type n_active_elem_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:375
virtual element_iterator active_type_elements_begin(ElemType type)=0
void add_ghosting_functor(GhostingFunctor &ghosting_functor)
Adds a functor which can specify ghosting requirements for use on distributed meshes.
Definition: mesh_base.h:786
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
virtual element_iterator local_not_level_elements_begin(unsigned int level)=0
MeshBase & operator=(const MeshBase &other)
The default shallow assignment operator is a very bad idea, so we&#39;ll make it a compile-time error to ...
virtual element_iterator pid_elements_end(processor_id_type proc_id)=0