libMesh
mesh_base.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 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/dof_object.h" // for invalid_processor_id
25 #include "libmesh/enum_order.h"
26 #include "libmesh/int_range.h"
27 #include "libmesh/libmesh_common.h"
28 #include "libmesh/multi_predicates.h"
29 #include "libmesh/point_locator_base.h"
30 #include "libmesh/variant_filter_iterator.h"
31 #include "libmesh/parallel_object.h"
32 #include "libmesh/simple_range.h"
33 
34 // C++ Includes
35 #include <cstddef>
36 #include <string>
37 #include <memory>
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 class BoundaryInfo;
49 
50 template <typename T>
51 class SparseMatrix;
52 
53 enum ElemType : int;
54 enum ElemMappingType : unsigned char;
55 
56 template <class MT>
57 class MeshInput;
58 
59 
75 class MeshBase : public ParallelObject
76 {
77 public:
78 
84  MeshBase (const Parallel::Communicator & comm_in,
85  unsigned char dim=1);
86 
90  MeshBase (const MeshBase & other_mesh);
91 
97  MeshBase(MeshBase &&) = delete;
98 
109  MeshBase & operator= (const MeshBase &) = delete;
110  MeshBase & operator= (MeshBase && other_mesh);
111 
116  virtual MeshBase & assign(MeshBase && other_mesh) = 0;
117 
131  bool operator== (const MeshBase & other_mesh) const;
132 
133  bool operator!= (const MeshBase & other_mesh) const
134  {
135  return !(*this == other_mesh);
136  }
137 
143  bool locally_equals (const MeshBase & other_mesh) const;
144 
150  virtual std::unique_ptr<MeshBase> clone() const = 0;
151 
155  virtual ~MeshBase ();
156 
160  virtual std::unique_ptr<Partitioner> & partitioner() { return _partitioner; }
161 
165  const BoundaryInfo & get_boundary_info() const { return *boundary_info; }
166 
171 
179  virtual void clear ();
180 
192  virtual void clear_elems () = 0;
193 
198  bool is_prepared () const
199  { return _is_prepared; }
200 
205  { _is_prepared = false; }
206 
211  virtual bool is_serial () const
212  { return true; }
213 
218  virtual bool is_serial_on_zero () const
219  { return true; }
220 
226  virtual void set_distributed ()
227  { libmesh_error(); }
228 
233  virtual bool is_replicated () const
234  { return true; }
235 
240  virtual void allgather () {}
241 
246  virtual void gather_to_zero() {}
247 
253  virtual void delete_remote_elements () {}
254 
259 
266  unsigned int mesh_dimension () const;
267 
275  void set_mesh_dimension (unsigned char d)
276  { _elem_dims.clear(); _elem_dims.insert(d); }
277 
282  const std::set<unsigned char> & elem_dimensions() const
283  { return _elem_dims; }
284 
289  const std::set<Order> & elem_default_orders() const
290  { return _elem_default_orders; }
291 
298  { return _supported_nodal_order; }
299 
310  void set_elem_dimensions(std::set<unsigned char> elem_dims);
311 
318  typedef std::set<elemset_id_type> elemset_type;
319 
342 
348  unsigned int n_elemsets() const;
349 
356  void get_elemsets(dof_id_type elemset_code, MeshBase::elemset_type & id_set_to_fill) const;
358 
363  std::vector<dof_id_type> get_elemset_codes() const;
364 
371  void change_elemset_code(dof_id_type old_code, dof_id_type new_code);
372 
378 
404  unsigned int spatial_dimension () const;
405 
410  void set_spatial_dimension(unsigned char d);
411 
421  virtual dof_id_type n_nodes () const = 0;
422 
432  virtual dof_id_type parallel_n_nodes () const = 0;
433 
437  dof_id_type n_nodes_on_proc (const processor_id_type proc) const;
438 
443  { return this->n_nodes_on_proc (this->processor_id()); }
444 
450 
455  virtual dof_id_type max_node_id () const = 0;
456 
457 #ifdef LIBMESH_ENABLE_UNIQUE_ID
458 
462 
472  virtual void set_next_unique_id(unique_id_type id) = 0;
473 #endif
474 
483  virtual void reserve_nodes (const dof_id_type nn) = 0;
484 
492  virtual dof_id_type n_elem () const = 0;
493 
501  virtual dof_id_type parallel_n_elem () const = 0;
502 
507  virtual dof_id_type max_elem_id () const = 0;
508 
513 #ifdef LIBMESH_ENABLE_UNIQUE_ID
514  virtual unique_id_type parallel_max_unique_id () const = 0;
515 #endif
516 
525  virtual void reserve_elem (const dof_id_type ne) = 0;
526 
531  virtual void update_parallel_id_counts () = 0;
532 
538  virtual dof_id_type n_active_elem () const = 0;
539 
543  dof_id_type n_elem_on_proc (const processor_id_type proc) const;
544 
549  { return this->n_elem_on_proc (this->processor_id()); }
550 
556 
561 
566  { return this->n_active_elem_on_proc (this->processor_id()); }
567 
577  dof_id_type n_sub_elem () const;
578 
583 
589  virtual const Point & point (const dof_id_type i) const = 0;
590 
596  virtual const Node & node_ref (const dof_id_type i) const
597  {
598  return *this->node_ptr(i);
599  }
600 
605  virtual Node & node_ref (const dof_id_type i)
606  {
607  return *this->node_ptr(i);
608  }
609 
614  virtual const Node * node_ptr (const dof_id_type i) const = 0;
615 
621  virtual Node * node_ptr (const dof_id_type i) = 0;
622 
627  virtual const Node * query_node_ptr (const dof_id_type i) const = 0;
628 
633  virtual Node * query_node_ptr (const dof_id_type i) = 0;
634 
639  virtual const Elem & elem_ref (const dof_id_type i) const
640  {
641  return *this->elem_ptr(i);
642  }
643 
649  virtual Elem & elem_ref (const dof_id_type i)
650  {
651  return *this->elem_ptr(i);
652  }
653 
658  virtual const Elem * elem_ptr (const dof_id_type i) const = 0;
659 
665  virtual Elem * elem_ptr (const dof_id_type i) = 0;
666 
671  virtual const Elem * query_elem_ptr (const dof_id_type i) const = 0;
672 
677  virtual Elem * query_elem_ptr (const dof_id_type i) = 0;
678 
689  virtual Node * add_point (const Point & p,
691  const processor_id_type proc_id =
693 
697  virtual Node * add_node (Node * n) = 0;
698 
707  virtual Node * add_node (std::unique_ptr<Node> n) = 0;
708 
709 #ifdef LIBMESH_ENABLE_DEPRECATED
710 
717  virtual Node * insert_node(Node * n) = 0;
718 
726  virtual Node * insert_node(std::unique_ptr<Node> n) = 0;
727 #endif
728 
732  virtual void delete_node (Node * n) = 0;
733 
740  virtual void own_node (Node &) {}
741 
747  virtual void renumber_node (dof_id_type old_id, dof_id_type new_id) = 0;
748 
758  virtual Elem * add_elem (Elem * e) = 0;
759 
768  virtual Elem * add_elem (std::unique_ptr<Elem> e) = 0;
769 
777  virtual Elem * insert_elem (Elem * e) = 0;
778 
787  virtual Elem * insert_elem (std::unique_ptr<Elem> e) = 0;
788 
799  virtual void delete_elem (Elem * e) = 0;
800 
806  virtual void renumber_elem (dof_id_type old_id, dof_id_type new_id) = 0;
807 
813  {
814  return _default_mapping_type;
815  }
816 
822  {
823  _default_mapping_type = type;
824  }
825 
830  unsigned char default_mapping_data () const
831  {
832  return _default_mapping_data;
833  }
834 
839  void set_default_mapping_data (const unsigned char data)
840  {
841  _default_mapping_data = data;
842  }
843 
856  virtual void find_neighbors (const bool reset_remote_elements = false,
857  const bool reset_current_list = true) = 0;
858 
863  void remove_orphaned_nodes ();
864 
870  virtual void renumber_nodes_and_elements () = 0;
871 
878  virtual void fix_broken_node_and_element_numbering () = 0;
879 
880 
881 #ifdef LIBMESH_ENABLE_AMR
882 
887  virtual bool contract () = 0;
888 #endif
889 
907  unsigned int add_elem_integer(std::string name,
908  bool allocate_data = true,
909  dof_id_type default_value = DofObject::invalid_id);
910 
925  std::vector<unsigned int> add_elem_integers(const std::vector<std::string> & names,
926  bool allocate_data = true,
927  const std::vector<dof_id_type> * default_values = nullptr);
928 
929  /*
930  * \returns The index number for the named extra element integer
931  * datum, which must have already been added.
932  */
933  unsigned int get_elem_integer_index(std::string_view name) const;
934 
935  /*
936  * \returns Whether or not the mesh has an element integer with its name.
937  */
938  bool has_elem_integer(std::string_view name) const;
939 
940  /*
941  * \returns The name for the indexed extra element integer
942  * datum, which must have already been added.
943  */
944  const std::string & get_elem_integer_name(unsigned int i) const
945  { return _elem_integer_names[i]; }
946 
947  /*
948  * \returns The number of extra element integers for which space is
949  * being reserved on this mesh.
950  *
951  * If non-integer data has been associated, each datum of type T
952  * counts for sizeof(T)/sizeof(dof_id_type) times in the return
953  * value.
954  */
955  unsigned int n_elem_integers() const { return _elem_integer_names.size(); }
956 
982  template <typename T>
983  unsigned int add_elem_datum(const std::string & name,
984  bool allocate_data = true,
985  const T * default_value = nullptr);
986 
1007  template <typename T>
1008  std::vector<unsigned int> add_elem_data(const std::vector<std::string> & names,
1009  bool allocate_data = true,
1010  const std::vector<T> * default_values = nullptr);
1011 
1029  unsigned int add_node_integer(std::string name,
1030  bool allocate_data = true,
1031  dof_id_type default_value = DofObject::invalid_id);
1032 
1047  std::vector<unsigned int> add_node_integers(const std::vector<std::string> & names,
1048  bool allocate_data = true,
1049  const std::vector<dof_id_type> * default_values = nullptr);
1050 
1051  /*
1052  * \returns The index number for the named extra node integer
1053  * datum, which must have already been added.
1054  */
1055  unsigned int get_node_integer_index(std::string_view name) const;
1056 
1057  /*
1058  * \returns Whether or not the mesh has a node integer with its name.
1059  */
1060  bool has_node_integer(std::string_view name) const;
1061 
1062  /*
1063  * \returns The name for the indexed extra node integer
1064  * datum, which must have already been added.
1065  */
1066  const std::string & get_node_integer_name(unsigned int i) const
1067  { return _node_integer_names[i]; }
1068 
1069  /*
1070  * \returns The number of extra node integers for which space is
1071  * being reserved on this mesh.
1072  *
1073  * If non-integer data has been associated, each datum of type T
1074  * counts for sizeof(T)/sizeof(dof_id_type) times in the return
1075  * value.
1076  */
1077  unsigned int n_node_integers() const { return _node_integer_names.size(); }
1078 
1104  template <typename T>
1105  unsigned int add_node_datum(const std::string & name,
1106  bool allocate_data = true,
1107  const T * default_value = nullptr);
1108 
1129  template <typename T>
1130  std::vector<unsigned int> add_node_data(const std::vector<std::string> & name,
1131  bool allocate_data = true,
1132  const std::vector<T> * default_values = nullptr);
1133 
1151 #ifdef LIBMESH_ENABLE_DEPRECATED
1152  void prepare_for_use (const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors);
1153  void prepare_for_use (const bool skip_renumber_nodes_and_elements);
1154 #endif // LIBMESH_ENABLE_DEPRECATED
1155  void prepare_for_use ();
1156 
1160  virtual void partition (const unsigned int n_parts);
1161 
1162  void partition ()
1163  { this->partition(this->n_processors()); }
1164 
1171  virtual void redistribute ();
1172 
1177  virtual void update_post_partitioning () {}
1178 
1198 
1203  void allow_find_neighbors(bool allow) { _skip_find_neighbors = !allow; }
1204  bool allow_find_neighbors() const { return !_skip_find_neighbors; }
1205 
1214 
1237  { _skip_noncritical_partitioning = skip; }
1238 
1241 
1242 
1254  void skip_partitioning(bool skip) { _skip_all_partitioning = skip; }
1255 
1257 
1267  void add_ghosting_functor(GhostingFunctor & ghosting_functor)
1268  { _ghosting_functors.insert(&ghosting_functor); }
1269 
1278  void add_ghosting_functor(std::shared_ptr<GhostingFunctor> ghosting_functor)
1279  { _shared_functors[ghosting_functor.get()] = ghosting_functor;
1280  this->add_ghosting_functor(*ghosting_functor); }
1281 
1286  void remove_ghosting_functor(GhostingFunctor & ghosting_functor);
1287 
1291  std::set<GhostingFunctor *>::const_iterator ghosting_functors_begin() const
1292  { return _ghosting_functors.begin(); }
1293 
1297  std::set<GhostingFunctor *>::const_iterator ghosting_functors_end() const
1298  { return _ghosting_functors.end(); }
1299 
1304 
1317  void subdomain_ids (std::set<subdomain_id_type> & ids, const bool global = true) const;
1318 
1327 
1336 
1345  unsigned int n_partitions () const
1346  { return _n_parts; }
1347 
1364  std::string get_info (const unsigned int verbosity = 0, const bool global = true) const;
1365 
1372  void print_info (std::ostream & os=libMesh::out, const unsigned int verbosity = 0, const bool global = true) const;
1373 
1379  friend std::ostream & operator << (std::ostream & os, const MeshBase & m);
1380 
1385  virtual void read (const std::string & name,
1386  void * mesh_data=nullptr,
1387  bool skip_renumber_nodes_and_elements=false,
1388  bool skip_find_neighbors=false) = 0;
1389  virtual void write (const std::string & name) const = 0;
1390 
1397  virtual void all_first_order () = 0;
1398 
1404 
1412  struct element_iterator;
1413  struct const_element_iterator;
1414 
1422  struct node_iterator;
1423  struct const_node_iterator;
1424 
1436  virtual void all_second_order_range(const SimpleRange<element_iterator> & range,
1437  const bool full_ordered = true) = 0;
1438 
1443  void all_second_order (const bool full_ordered = true);
1444 
1452  virtual void all_complete_order_range(const SimpleRange<element_iterator> & range) = 0;
1453 
1458  virtual void all_complete_order ();
1459 
1469  unsigned int recalculate_n_partitions();
1470 
1478  std::unique_ptr<PointLocatorBase> sub_point_locator () const;
1479 
1491 
1495  void clear_point_locator ();
1496 
1502  void set_count_lower_dim_elems_in_point_locator(bool count_lower_dim_elems);
1503 
1508 
1516  virtual void libmesh_assert_valid_parallel_ids() const {}
1517 
1522  std::string & subdomain_name(subdomain_id_type id);
1523  const std::string & subdomain_name(subdomain_id_type id) const;
1524 
1529  subdomain_id_type get_id_by_name(std::string_view name) const;
1530 
1531  /*
1532  * We have many combinations of iterators that filter on various
1533  * characteristics; we use macros to make their abstract base class
1534  * and their subclass declarations more terse.
1535  */
1536 #define ABSTRACT_ELEM_ITERATORS(TYPE, ARGDECL) \
1537  virtual element_iterator TYPE##elements_begin(ARGDECL) = 0; \
1538  virtual element_iterator TYPE##elements_end(ARGDECL) = 0; \
1539  virtual const_element_iterator TYPE##elements_begin(ARGDECL) const = 0; \
1540  virtual const_element_iterator TYPE##elements_end(ARGDECL) const = 0; \
1541  virtual SimpleRange<element_iterator> TYPE##element_ptr_range(ARGDECL) = 0; \
1542  virtual SimpleRange<const_element_iterator> TYPE##element_ptr_range(ARGDECL) const = 0;
1543 
1544 #define DECLARE_ELEM_ITERATORS(TYPE, ARGDECL, ARGS) \
1545  virtual element_iterator TYPE##elements_begin(ARGDECL) override final; \
1546  virtual element_iterator TYPE##elements_end(ARGDECL) override final; \
1547  virtual const_element_iterator TYPE##elements_begin(ARGDECL) const override final; \
1548  virtual const_element_iterator TYPE##elements_end(ARGDECL) const override final; \
1549  virtual SimpleRange<element_iterator> TYPE##element_ptr_range(ARGDECL) override final { return {TYPE##elements_begin(ARGS), TYPE##elements_end(ARGS)}; } \
1550  virtual SimpleRange<const_element_iterator> TYPE##element_ptr_range(ARGDECL) const override final { return {TYPE##elements_begin(ARGS), TYPE##elements_end(ARGS)}; }
1551 
1552 #define ABSTRACT_NODE_ITERATORS(TYPE, ARGDECL) \
1553  virtual node_iterator TYPE##nodes_begin(ARGDECL) = 0; \
1554  virtual node_iterator TYPE##nodes_end(ARGDECL) = 0; \
1555  virtual const_node_iterator TYPE##nodes_begin(ARGDECL) const = 0; \
1556  virtual const_node_iterator TYPE##nodes_end(ARGDECL) const = 0; \
1557  virtual SimpleRange<node_iterator> TYPE##node_ptr_range(ARGDECL) = 0; \
1558  virtual SimpleRange<const_node_iterator> TYPE##node_ptr_range(ARGDECL) const = 0;
1559 
1560 #define DECLARE_NODE_ITERATORS(TYPE, ARGDECL, ARGS) \
1561  virtual node_iterator TYPE##nodes_begin(ARGDECL) override final; \
1562  virtual node_iterator TYPE##nodes_end(ARGDECL) override final; \
1563  virtual const_node_iterator TYPE##nodes_begin(ARGDECL) const override final; \
1564  virtual const_node_iterator TYPE##nodes_end(ARGDECL) const override final; \
1565  virtual SimpleRange<node_iterator> TYPE##node_ptr_range(ARGDECL) override final { return {TYPE##nodes_begin(ARGS), TYPE##nodes_end(ARGS)}; } \
1566  virtual SimpleRange<const_node_iterator> TYPE##node_ptr_range(ARGDECL) const override final { return {TYPE##nodes_begin(ARGS), TYPE##nodes_end(ARGS)}; }
1567 
1568 #define LIBMESH_COMMA ,
1569 
1570  /*
1571  * element_iterator accessors
1572  *
1573  * The basic elements_begin() and elements_end() iterators iterate
1574  * over all elements in a mesh, returning element pointers or const
1575  * element pointers when dereferenced (depending on whether the mesh
1576  * reference was const). range-for loops can be written using
1577  * element_ptr_range()
1578  *
1579  * Filtered versions of these iterators, which skip over all
1580  * elements not matching some predicate, are also available, by
1581  * adding a prefix to the methods above. E.g. local_ (in a form
1582  * like local_elements_begin() or local_element_ptr_range()) will
1583  * iterate only over elements whose processor_id() is the current
1584  * processor, or active_ will iterate only over active elements even
1585  * if the mesh is refined, or active_local_ will iterate over
1586  * elements that are both active and local. Negation forms such as
1587  * not_local_ also exist.
1588  *
1589  * For some iterator prefixes, such as type_, an argument is needed
1590  * for the filter; e.g. the ElemType to select for in that case.
1591  *
1592  * All valid prefixes and their corresponding arguments can be found
1593  * in the macro invocations below.
1594  */
1595  ABSTRACT_ELEM_ITERATORS(,) // elements_begin(), element_ptr_range(): all elements
1596  ABSTRACT_ELEM_ITERATORS(active_,) // Elem::active() == true
1597  ABSTRACT_ELEM_ITERATORS(ancestor_,) // Elem::ancestor() == true
1598  ABSTRACT_ELEM_ITERATORS(subactive_,) // Elem::subactive() == true
1599  ABSTRACT_ELEM_ITERATORS(local_,) // Elem::processor_id() == this processor
1600  ABSTRACT_ELEM_ITERATORS(unpartitioned_,) // Elem::processor_id() == invalid_processor_id
1601  ABSTRACT_ELEM_ITERATORS(facelocal_,) // is on or has a neighbor on this processor
1602  ABSTRACT_ELEM_ITERATORS(level_,unsigned int level) // Elem::level() == level
1603  ABSTRACT_ELEM_ITERATORS(pid_,processor_id_type pid) // Elem::processor_id() == pid
1604  ABSTRACT_ELEM_ITERATORS(type_,ElemType type) // Elem::type() == type
1605 
1606  ABSTRACT_ELEM_ITERATORS(active_subdomain_,subdomain_id_type sid) // active && Elem::subdomain_id() == sid
1607  ABSTRACT_ELEM_ITERATORS(active_subdomain_set_,std::set<subdomain_id_type> ss) // active && ss.contains(Elem::subdomain_id())
1608 
1609  // Iterators which use negations of filters described above
1610  ABSTRACT_ELEM_ITERATORS(not_active_,)
1611  ABSTRACT_ELEM_ITERATORS(not_ancestor_,)
1612  ABSTRACT_ELEM_ITERATORS(not_subactive_,)
1613  ABSTRACT_ELEM_ITERATORS(not_local_,)
1614  ABSTRACT_ELEM_ITERATORS(not_level_,unsigned int level)
1615 
1616  // Iterators which combine multiple of the filters described above
1617  ABSTRACT_ELEM_ITERATORS(active_local_,)
1618  ABSTRACT_ELEM_ITERATORS(active_not_local_,)
1619  ABSTRACT_ELEM_ITERATORS(active_unpartitioned_,)
1620  ABSTRACT_ELEM_ITERATORS(active_type_,ElemType type)
1622  ABSTRACT_ELEM_ITERATORS(local_level_,unsigned int level)
1623  ABSTRACT_ELEM_ITERATORS(local_not_level_,unsigned int level)
1624  ABSTRACT_ELEM_ITERATORS(active_local_subdomain_,subdomain_id_type sid)
1625  ABSTRACT_ELEM_ITERATORS(active_local_subdomain_set_,std::set<subdomain_id_type> ss)
1626 
1627  // Backwards compatibility
1628  virtual SimpleRange<element_iterator> active_subdomain_elements_ptr_range(subdomain_id_type sid) = 0;
1629  virtual SimpleRange<const_element_iterator> active_subdomain_elements_ptr_range(subdomain_id_type sid) const = 0;
1630  virtual SimpleRange<element_iterator> active_local_subdomain_elements_ptr_range(subdomain_id_type sid) = 0;
1631  virtual SimpleRange<const_element_iterator> active_local_subdomain_elements_ptr_range(subdomain_id_type sid) const = 0;
1632  virtual SimpleRange<element_iterator> active_subdomain_set_elements_ptr_range(std::set<subdomain_id_type> ss) = 0;
1633  virtual SimpleRange<const_element_iterator> active_subdomain_set_elements_ptr_range(std::set<subdomain_id_type> ss) const = 0;
1634 
1635  // Discouraged from use - these iterators use outdated
1636  // pre-GhostingFunctor definitions and should be renamed if not
1637  // deprecated
1638  ABSTRACT_ELEM_ITERATORS(semilocal_,) // active && Elem::is_semilocal()
1639  ABSTRACT_ELEM_ITERATORS(ghost_,) // active && Elem::is_semilocal() && not local discouraged
1640  ABSTRACT_ELEM_ITERATORS(active_semilocal_,)
1641 
1642  // solution can be evaluated, with the given DoF map, for the given
1643  // variable number, or for all variables by default
1644  ABSTRACT_ELEM_ITERATORS(evaluable_,const DofMap & dof_map LIBMESH_COMMA unsigned int var_num = libMesh::invalid_uint)
1645 
1646  // solution can be evaluated for all variables of all given DoF maps
1647  ABSTRACT_ELEM_ITERATORS(multi_evaluable_,std::vector<const DofMap *> dof_maps)
1648 
1649 #ifdef LIBMESH_ENABLE_AMR
1650  ABSTRACT_ELEM_ITERATORS(flagged_,unsigned char rflag) // Elem::refinement_flag() == rflag
1651 
1652  // Elem::refinement_flag() == rflag && Elem::processor_id() == pid
1653  ABSTRACT_ELEM_ITERATORS(flagged_pid_,unsigned char rflag LIBMESH_COMMA processor_id_type pid)
1654 #endif
1655 
1656  /*
1657  * node_iterator accessors
1658  *
1659  * The basic nodes_begin() and nodes_end() iterators iterate
1660  * over all nodes in a mesh, returning node pointers or const
1661  * node pointers when dereferenced (depending on whether the mesh
1662  * reference was const). range-for loops can be written using
1663  * node_ptr_range()
1664  *
1665  * Filtered versions of these iterators, which skip over all
1666  * nodes not matching some predicate, are also available, by
1667  * adding a prefix to the methods above. E.g. local_ (in a form
1668  * like local_nodes_begin() or local_node_ptr_range()) will
1669  * iterate only over nodes whose processor_id() is the current
1670  * processor.
1671  *
1672  * All valid prefixes and their corresponding arguments can be found
1673  * in the macro invocations below.
1674  */
1675  ABSTRACT_NODE_ITERATORS(,) // nodes_begin(), node_ptr_range(): all nodes
1676  ABSTRACT_NODE_ITERATORS(active_,) // Node::active() == true; i.e. Node::id() != invalid_id
1677  ABSTRACT_NODE_ITERATORS(local_,) // Node::processor_id() == this processor
1678  ABSTRACT_NODE_ITERATORS(bnd_,) // BoundaryInfo::n_boundary_ids(node) > 0
1679  ABSTRACT_NODE_ITERATORS(pid_,processor_id_type pid) // Node::processor_id() == pid
1680  ABSTRACT_NODE_ITERATORS(bid_,boundary_id_type bid) // BoundaryInfo::has_boundary_id(node, bid)
1681 
1682  // solution can be evaluated, with the given DoF map, for the given
1683  // variable number, or for all variables by default
1684  ABSTRACT_NODE_ITERATORS(evaluable_,const DofMap & dof_map LIBMESH_COMMA unsigned int var_num = libMesh::invalid_uint)
1685 
1686  // solution can be evaluated for all variables of all given DoF maps
1687  ABSTRACT_NODE_ITERATORS(multi_evaluable_,std::vector<const DofMap *> dof_maps)
1688 
1693  { return _block_id_to_name; }
1694  const std::map<subdomain_id_type, std::string> & get_subdomain_name_map () const
1695  { return _block_id_to_name; }
1696 
1697  typedef std::vector<std::pair<std::pair<const Elem *, unsigned int>, Real>> constraint_rows_mapped_type;
1698  typedef std::map<const Node *, constraint_rows_mapped_type> constraint_rows_type;
1699 
1704  { return _constraint_rows; }
1705 
1707  { return _constraint_rows; }
1708 
1710 
1714  void copy_constraint_rows(const MeshBase & other_mesh);
1715 
1743  template <typename T>
1744  void copy_constraint_rows(const SparseMatrix<T> & constraint_operator,
1745  bool precondition_constraint_operator = false);
1746 
1753  void print_constraint_rows(std::ostream & os=libMesh::out,
1754  bool print_nonlocal=false) const;
1755 
1761  std::string get_local_constraints(bool print_nonlocal=false) const;
1762 
1763 #ifdef LIBMESH_ENABLE_DEPRECATED
1764 
1771  void cache_elem_dims();
1772 #endif // LIBMESH_ENABLE_DEPRECATED
1773 
1774  /*
1775  * Search the mesh and cache data for the elements
1776  * present in the mesh. This is done in prepare_for_use(), but can
1777  * be done manually by other classes after major mesh modifications.
1778  * Data cached includes:
1779  * - elem dimensions
1780  * - elem subdomains
1781  */
1782  void cache_elem_data();
1783 
1788  void detect_interior_parents();
1789 
1797  const MeshBase & interior_mesh() const { return *_interior_mesh; }
1798 
1803 
1807  void set_interior_mesh(MeshBase & int_mesh) { _interior_mesh = &int_mesh; }
1808 
1814  const std::set<subdomain_id_type> & get_mesh_subdomains() const
1815  { libmesh_assert(this->is_prepared()); return _mesh_subdomains; }
1816 
1817 
1827 #ifndef LIBMESH_ENABLE_DEPRECATED
1828 protected:
1829 #endif
1830  std::unique_ptr<BoundaryInfo> boundary_info;
1831 
1832 
1833 protected:
1842  void post_dofobject_moves(MeshBase && other_mesh);
1843 
1848  void copy_cached_data (const MeshBase & other_mesh);
1849 
1854  virtual bool subclass_locally_equals (const MeshBase & other_mesh) const = 0;
1855 
1860  bool nodes_and_elements_equal(const MeshBase & other_mesh) const;
1861 
1865  unsigned int & set_n_partitions ()
1866  { return _n_parts; }
1867 
1878  unsigned int _n_parts;
1879 
1885 
1891  unsigned char _default_mapping_data;
1892 
1897 
1905  mutable std::unique_ptr<PointLocatorBase> _point_locator;
1906 
1912 
1919  std::unique_ptr<Partitioner> _partitioner;
1920 
1921 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1922 
1926 #endif
1927 
1933 
1939 
1944 
1951 
1956 
1964 
1970  std::map<subdomain_id_type, std::string> _block_id_to_name;
1971 
1977  std::set<unsigned char> _elem_dims;
1978 
1984  std::set<Order> _elem_default_orders;
1985 
1991 
1995  std::set<subdomain_id_type> _mesh_subdomains;
1996 
2019  std::map<dof_id_type, const MeshBase::elemset_type *> _elemset_codes;
2020  std::map<MeshBase::elemset_type, dof_id_type> _elemset_codes_inverse_map;
2022 
2027  unsigned char _spatial_dimension;
2028 
2033  std::vector<std::string> _elem_integer_names;
2034 
2039  std::vector<dof_id_type> _elem_integer_default_values;
2040 
2045  std::vector<std::string> _node_integer_names;
2046 
2051  std::vector<dof_id_type> _node_integer_default_values;
2052 
2056  void size_elem_extra_integers();
2057 
2061  void size_node_extra_integers();
2062 
2069  std::pair<std::vector<unsigned int>, std::vector<unsigned int>>
2070  merge_extra_integer_names(const MeshBase & other);
2071 
2077  std::unique_ptr<GhostingFunctor> _default_ghosting;
2078 
2086  std::set<GhostingFunctor *> _ghosting_functors;
2087 
2092  std::map<GhostingFunctor *, std::shared_ptr<GhostingFunctor> > _shared_functors;
2093 
2094  // Keep track of any constraint equations that are inherent to the
2095  // mesh, such as FE nodes whose Rational Bernstein values need to be
2096  // constrained in terms of values on spline control nodes.
2097  //
2098  // _constraint_rows[constrained_node][i].first.first is an
2099  // element (e.g. a NodeElem for a spline control node),
2100  // _constraint_rows[constrained_node][i].first.second is the
2101  // local node id of that element which is a constraining node,
2102  // _constraint_rows[constrained_node][i].second is that node's
2103  // constraint coefficient.
2105 
2111 
2116  friend class Partitioner;
2117 
2122  friend class MeshInput<MeshBase>;
2123 
2128  friend class BoundaryInfo;
2129 
2134  friend class MeshCommunication;
2135 
2136 
2141 #ifdef LIBMESH_ENABLE_DEPRECATED
2143 
2145  Elem * const,
2146  Elem * const &,
2148 
2150 
2152  Node * const,
2153  Node * const &,
2155 #else
2157  Elem * const,
2158  Elem * const &,
2159  Elem * const *,
2160  const Elem * const,
2161  const Elem * const &,
2162  const Elem * const *> elem_filter_iter;
2163 
2165  const Elem * const,
2166  const Elem * const &,
2167  const Elem * const *> const_elem_filter_iter;
2168 
2170  Node * const,
2171  Node * const &,
2172  Node * const *,
2173  const Node * const,
2174  const Node * const &,
2175  const Node * const *> node_filter_iter;
2176 
2178  const Node * const,
2179  const Node * const &,
2180  const Node * const *> const_node_filter_iter;
2181 #endif // LIBMESH_ENABLE_DEPRECATED
2182 
2183 };
2184 
2185 
2186 
2187 
2188 
2189 
2190 
2191 
2192 
2193 
2194 
2198 struct
2200 {
2201  // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
2202  template <typename PredType, typename IterType>
2203  element_iterator (const IterType & d,
2204  const IterType & e,
2205  const PredType & p ) :
2206  elem_filter_iter(d,e,p) {}
2207 };
2208 
2209 
2210 
2211 
2216 struct
2218 {
2222  template <typename PredType, typename IterType>
2223  const_element_iterator (const IterType & d,
2224  const IterType & e,
2225  const PredType & p ) :
2226  const_elem_filter_iter(d,e,p) {}
2227 
2235  const_elem_filter_iter(rhs) {}
2236 };
2237 
2238 
2239 
2240 
2241 
2242 
2243 
2247 struct
2249 {
2253  template <typename PredType, typename IterType>
2254  node_iterator (const IterType & d,
2255  const IterType & e,
2256  const PredType & p ) :
2257  node_filter_iter(d,e,p) {}
2258 };
2259 
2260 
2261 
2262 
2267 struct
2269 {
2273  template <typename PredType, typename IterType>
2274  const_node_iterator (const IterType & d,
2275  const IterType & e,
2276  const PredType & p ) :
2277  const_node_filter_iter(d,e,p) {}
2278 
2286  const_node_filter_iter(rhs) {}
2287 };
2288 
2289 
2290 template <typename T>
2291 inline
2292 unsigned int MeshBase::add_elem_datum(const std::string & name,
2293  bool allocate_data,
2294  const T * default_value)
2295 {
2296  const std::size_t old_size = _elem_integer_names.size();
2297 
2298  unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
2299  std::vector<dof_id_type> int_data(n_more_integers+1, DofObject::invalid_id);
2300  if (default_value)
2301  std::memcpy(int_data.data(), default_value, sizeof(T));
2302 
2303  unsigned int start_idx = this->add_elem_integer(name, false, int_data[0]);
2304  for (unsigned int i=0; i != n_more_integers; ++i)
2305  this->add_elem_integer(name+"__"+std::to_string(i), false, int_data[i+1]);
2306 
2307  if (allocate_data && old_size != _elem_integer_names.size())
2308  this->size_elem_extra_integers();
2309 
2310  return start_idx;
2311 }
2312 
2313 
2314 template <typename T>
2315 inline
2316 std::vector<unsigned int> MeshBase::add_elem_data(const std::vector<std::string> & names,
2317  bool allocate_data,
2318  const std::vector<T> * default_values)
2319 {
2320  libmesh_assert(!default_values || default_values->size() == names.size());
2321 
2322  std::vector<unsigned int> returnval(names.size());
2323 
2324  const std::size_t old_size = _elem_integer_names.size();
2325 
2326  for (auto i : index_range(names))
2327  returnval[i] =
2328  this->add_elem_datum<T>(names[i], false,
2329  default_values ?
2330  (*default_values)[i] : nullptr);
2331 
2332  if (allocate_data && old_size != _elem_integer_names.size())
2333  this->size_elem_extra_integers();
2334 
2335  return returnval;
2336 }
2337 
2338 
2339 template <typename T>
2340 inline
2341 unsigned int MeshBase::add_node_datum(const std::string & name,
2342  bool allocate_data,
2343  const T * default_value)
2344 {
2345  const std::size_t old_size = _node_integer_names.size();
2346 
2347  unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
2348  std::vector<dof_id_type> int_data(n_more_integers+1, DofObject::invalid_id);
2349  if (default_value)
2350  std::memcpy(int_data.data(), default_value, sizeof(T));
2351 
2352  unsigned int start_idx = this->add_node_integer(name, false, int_data[0]);
2353  for (unsigned int i=0; i != n_more_integers; ++i)
2354  this->add_node_integer(name+"__"+std::to_string(i), false, int_data[i+1]);
2355 
2356  if (allocate_data && old_size != _node_integer_names.size())
2357  this->size_node_extra_integers();
2358 
2359  return start_idx;
2360 }
2361 
2362 
2363 template <typename T>
2364 inline
2365 std::vector<unsigned int> MeshBase::add_node_data(const std::vector<std::string> & names,
2366  bool allocate_data,
2367  const std::vector<T> * default_values)
2368 {
2369  libmesh_assert(!default_values || default_values->size() == names.size());
2370 
2371  std::vector<unsigned int> returnval(names.size());
2372 
2373  const std::size_t old_size = _node_integer_names.size();
2374 
2375  for (auto i : index_range(names))
2376  returnval[i] =
2377  this->add_node_datum<T>(names[i], false,
2378  default_values ?
2379  (*default_values)[i] : nullptr);
2380 
2381  if (allocate_data && old_size != _node_integer_names.size())
2382  this->size_node_extra_integers();
2383 
2384  return returnval;
2385 }
2386 
2387 
2388 
2389 } // namespace libMesh
2390 
2391 #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:42
The definition of the element_iterator struct.
Definition: mesh_base.h:2198
bool operator==(const MeshBase &other_mesh) const
This tests for exactly-equal data in all the senses that a mathematician would care about (element co...
Definition: mesh_base.C:226
variant_filter_iterator< MeshBase::Predicate, Elem * > elem_filter_iter
The original iterator classes weren&#39;t properly const-safe; relying on their const-incorrectness is no...
Definition: mesh_base.h:2142
std::set< subdomain_id_type > _mesh_subdomains
We cache the subdomain ids of the elements present in the mesh.
Definition: mesh_base.h:1995
bool has_node_integer(std::string_view name) const
Definition: mesh_base.C:727
std::vector< unsigned int > add_elem_integers(const std::vector< std::string > &names, bool allocate_data=true, const std::vector< dof_id_type > *default_values=nullptr)
Register integer data (of type dof_id_type) to be added to each element in the mesh, one string name for each new integer.
Definition: mesh_base.C:583
ElemType
Defines an enum for geometric element types.
The SimpleRange templated class is intended to make it easy to construct ranges from pairs of iterato...
Definition: simple_range.h:36
bool operator!=(const MeshBase &other_mesh) const
Definition: mesh_base.h:133
const std::set< Order > & elem_default_orders() const
Definition: mesh_base.h:289
virtual void read(const std::string &name, void *mesh_data=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 void reserve_nodes(const dof_id_type nn)=0
Reserves space for a known number of nodes.
ABSTRACT_ELEM_ITERATORS(,) ABSTRACT_ELEM_ITERATORS(active_
virtual bool subclass_locally_equals(const MeshBase &other_mesh) const =0
Shim to allow operator == (&) to behave like a virtual function without having to be one...
bool _skip_renumber_nodes_and_elements
If this is true then renumbering will be kept to a minimum.
Definition: mesh_base.h:1950
bool is_prepared() const
Definition: mesh_base.h:198
Order
defines an enum for polynomial orders.
Definition: enum_order.h:40
constraint_rows_type & get_constraint_rows()
Constraint rows accessors.
Definition: mesh_base.h:1703
virtual dof_id_type n_active_elem() const =0
A Node is like a Point, but with more information.
Definition: node.h:52
This abstract base class defines the interface by which library code and user code can report associa...
const MeshBase & interior_mesh() const
Definition: mesh_base.h:1797
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 ...
Real get_point_locator_close_to_point_tol() const
Definition: mesh_base.C:1933
dof_id_type n_elem_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:1036
virtual unique_id_type parallel_max_unique_id() const =0
dof_id_type n_unpartitioned_nodes() const
Definition: mesh_base.h:448
void set_interior_mesh(MeshBase &int_mesh)
Sets the interior mesh.
Definition: mesh_base.h:1807
variant_filter_iterator< MeshBase::Predicate, Node * > node_filter_iter
Definition: mesh_base.h:2149
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition: libmesh.h:310
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition: mesh_base.h:2033
std::unique_ptr< PointLocatorBase > sub_point_locator() const
Definition: mesh_base.C:1638
unsigned int n_node_integers() const
Definition: mesh_base.h:1077
void remove_orphaned_nodes()
Removes any orphaned nodes, nodes not connected to any elements.
Definition: mesh_base.C:738
Original Authors: Corwin Joy * Michael Gradman [email protected] * [email protected] Caminus, Suite 1150, Two Allen Center, 1200 Smith Street, Houston, TX 77002 This class is an extension of variant_bidirectional_iterator to a filter_iterator similar to boost&#39;s.
std::vector< dof_id_type > get_elemset_codes() const
Return a vector of all elemset codes defined on the mesh.
Definition: mesh_base.C:445
BoundaryInfo & get_boundary_info()
Writable information about boundary ids on the mesh.
Definition: mesh_base.h:170
virtual void all_second_order_range(const SimpleRange< element_iterator > &range, const bool full_ordered=true)=0
Converts a set of this Mesh&#39;s elements defined by range from FIRST order to SECOND order...
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:1196
void add_ghosting_functor(std::shared_ptr< GhostingFunctor > ghosting_functor)
Adds a functor which can specify ghosting requirements for use on distributed meshes.
Definition: mesh_base.h:1278
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:1811
void skip_partitioning(bool skip)
If true is passed in then nothing on this mesh will be (re)partitioned.
Definition: mesh_base.h:1254
dof_id_type n_active_elem_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:1049
The definition of the const_element_iterator struct.
Definition: mesh_base.h:2216
unsigned int dim
MeshBase * _interior_mesh
Defaulting to this, a pointer to the mesh used to generate boundary elements on this.
Definition: mesh_base.h:1932
std::vector< std::pair< std::pair< const Elem *, unsigned int >, Real > > constraint_rows_mapped_type
Definition: mesh_base.h:1697
subdomain_id_type n_local_subdomains() const
Definition: mesh_base.C:1011
variant_filter_iterator< MeshBase::Predicate, const Elem *const, const Elem *const &, const Elem *const * > const_elem_filter_iter
Definition: mesh_base.h:2167
void copy_cached_data(const MeshBase &other_mesh)
Helper class to copy cached data, to synchronize with a possibly unprepared other_mesh.
Definition: mesh_base.C:2004
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:1403
virtual void allgather()
Gathers all elements and nodes of the mesh onto every processor.
Definition: mesh_base.h:240
void set_spatial_dimension(unsigned char d)
Sets the "spatial dimension" of the Mesh.
Definition: mesh_base.C:550
void set_isnt_prepared()
Tells this we have done some operation where we should no longer consider ourself prepared...
Definition: mesh_base.h:204
std::map< dof_id_type, const MeshBase::elemset_type * > _elemset_codes
Map from "element set code" to list of set ids to which that element belongs (and vice-versa)...
Definition: mesh_base.h:2019
bool skip_noncritical_partitioning() const
Definition: mesh_base.h:1239
unsigned int add_elem_integer(std::string name, bool allocate_data=true, dof_id_type default_value=DofObject::invalid_id)
Register an integer datum (of type dof_id_type) to be added to each element in the mesh...
Definition: mesh_base.C:560
void add_elemset_code(dof_id_type code, MeshBase::elemset_type id_set)
Tabulate a user-defined "code" for elements which belong to the element sets specified in id_set...
Definition: mesh_base.C:398
bool has_elem_integer(std::string_view name) const
Definition: mesh_base.C:638
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:1685
void remove_ghosting_functor(GhostingFunctor &ghosting_functor)
Removes a functor which was previously added to the set of ghosting functors.
Definition: mesh_base.C:948
unsigned int n_elem_integers() const
Definition: mesh_base.h:955
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
dof_id_type n_local_nodes() const
Definition: mesh_base.h:442
virtual std::unique_ptr< Partitioner > & partitioner()
A partitioner to use at each prepare_for_use()
Definition: mesh_base.h:160
constraint_rows_type _constraint_rows
Definition: mesh_base.h:2104
virtual void gather_to_zero()
Gathers all elements and nodes of the mesh onto processor zero.
Definition: mesh_base.h:246
void skip_noncritical_partitioning(bool skip)
If true is passed in then the elements on this mesh will no longer be (re)partitioned, and the nodes on this mesh will only be repartitioned if they are found "orphaned" via coarsening or other removal of the last element responsible for their node/element processor id consistency.
Definition: mesh_base.h:1236
void copy_constraint_rows(const MeshBase &other_mesh)
Copy the constraints from the other mesh to this mesh.
Definition: mesh_base.C:2063
std::vector< unsigned int > add_node_integers(const std::vector< std::string > &names, bool allocate_data=true, const std::vector< dof_id_type > *default_values=nullptr)
Register integer data (of type dof_id_type) to be added to each node in the mesh. ...
Definition: mesh_base.C:672
virtual Elem & elem_ref(const dof_id_type i)
Definition: mesh_base.h:649
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:2223
bool _skip_noncritical_partitioning
If this is true then no partitioning should be done with the possible exception of orphaned nodes...
Definition: mesh_base.h:1938
std::vector< unsigned int > add_node_data(const std::vector< std::string > &name, bool allocate_data=true, const std::vector< T > *default_values=nullptr)
Register data (of type T) to be added to each node in the mesh.
Definition: mesh_base.h:2365
virtual void fix_broken_node_and_element_numbering()=0
There is no reason for a user to ever call this function.
unsigned char _spatial_dimension
The "spatial dimension" of the Mesh.
Definition: mesh_base.h:2027
virtual void own_node(Node &)
Takes ownership of node n on this partition of a distributed mesh, by setting n.processor_id() to thi...
Definition: mesh_base.h:740
std::unique_ptr< BoundaryInfo > boundary_info
This class holds the boundary information.
Definition: mesh_base.h:1830
virtual void set_next_unique_id(unique_id_type id)=0
Sets the next available unique id to be used.
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:1963
The libMesh namespace provides an interface to certain functionality in the library.
std::map< MeshBase::elemset_type, dof_id_type > _elemset_codes_inverse_map
Definition: mesh_base.h:2020
virtual void all_first_order()=0
Converts a mesh with higher-order elements into a mesh with linear elements.
dof_id_type get_elemset_code(const MeshBase::elemset_type &id_set) const
Definition: mesh_base.C:439
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:165
dof_id_type n_unpartitioned_elem() const
Definition: mesh_base.h:554
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition: mesh_base.h:2045
virtual std::unique_ptr< MeshBase > clone() const =0
Virtual "copy constructor".
virtual Node & node_ref(const dof_id_type i)
Definition: mesh_base.h:605
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.
dof_id_type n_local_elem() const
Definition: mesh_base.h:548
MeshBase::elemset_type _all_elemset_ids
Definition: mesh_base.h:2021
dof_id_type n_constraint_rows() const
Definition: mesh_base.C:2044
const std::string & get_elem_integer_name(unsigned int i) const
Definition: mesh_base.h:944
bool nodes_and_elements_equal(const MeshBase &other_mesh) const
Tests for equality of all elements and nodes in the mesh.
Definition: mesh_base.C:2014
virtual MeshBase & assign(MeshBase &&other_mesh)=0
Shim to allow operator = (&&) to behave like a virtual function without having to be one...
uint8_t processor_id_type
Definition: id_types.h:104
This is the MeshBase class.
Definition: mesh_base.h:75
The Partitioner class provides a uniform interface for partitioning algorithms.
Definition: partitioner.h:51
ElemMappingType default_mapping_type() const
Returns the default master space to physical space mapping basis functions to be used on newly added ...
Definition: mesh_base.h:812
subdomain_id_type get_id_by_name(std::string_view name) const
Definition: mesh_base.C:1712
void get_elemsets(dof_id_type elemset_code, MeshBase::elemset_type &id_set_to_fill) const
Look up the element sets for a given elemset code and vice-versa.
Definition: mesh_base.C:429
virtual bool is_serial_on_zero() const
Definition: mesh_base.h:218
void change_elemset_code(dof_id_type old_code, dof_id_type new_code)
Replace elemset code "old_code" with "new_code".
Definition: mesh_base.C:454
virtual void all_complete_order_range(const SimpleRange< element_iterator > &range)=0
Converts a set of elements in this (conforming, non-refined) mesh into "complete" order elements...
virtual void set_distributed()
Asserts that not all elements and nodes of the mesh necessarily exist on the current processor...
Definition: mesh_base.h:226
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:2254
Generic sparse matrix.
Definition: vector_fe_ex5.C:46
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:179
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:2086
Order supported_nodal_order() const
Definition: mesh_base.h:297
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition: mesh_base.h:1925
unsigned int _n_parts
The number of partitions the mesh has.
Definition: mesh_base.h:1878
dof_id_type n_active_local_elem() const
Definition: mesh_base.h:565
unsigned int get_elem_integer_index(std::string_view name) const
Definition: mesh_base.C:626
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:1212
processor_id_type n_processors() const
virtual bool is_serial() const
Definition: mesh_base.h:211
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true)=0
Locate element face (edge in 2D) neighbors.
unsigned char _default_mapping_data
The default mapping data (unused with Lagrange, used for nodal weight lookup index with rational base...
Definition: mesh_base.h:1891
int8_t boundary_id_type
Definition: id_types.h:51
virtual void delete_elem(Elem *e)=0
Removes element e from the mesh.
This is the MeshCommunication class.
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
Definition: mesh_base.h:1694
This class defines an abstract interface for Mesh input.
Definition: mesh_base.h:57
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:493
dof_id_type n_sub_elem() const
Definition: mesh_base.C:1058
unsigned char default_mapping_data() const
Returns any default data value used by the master space to physical space mapping.
Definition: mesh_base.h:830
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
ElemMappingType _default_mapping_type
The default mapping type (typically Lagrange) between master and physical space to assign to newly ad...
Definition: mesh_base.h:1884
virtual void update_parallel_id_counts()=0
Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors...
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
Definition: mesh_base.C:1562
void cache_elem_data()
Definition: mesh_base.C:1733
std::unique_ptr< Partitioner > _partitioner
A partitioner to use at each prepare_for_use().
Definition: mesh_base.h:1919
virtual const Node * query_node_ptr(const dof_id_type i) const =0
void set_default_mapping_type(const ElemMappingType type)
Set the default master space to physical space mapping basis functions to be used on newly added elem...
Definition: mesh_base.h:821
virtual dof_id_type max_elem_id() const =0
void clear_point_locator()
Releases the current PointLocator object.
Definition: mesh_base.C:1671
variant_filter_iterator< MeshBase::Predicate, Elem *const, Elem *const &, Elem *const * > const_elem_filter_iter
Definition: mesh_base.h:2147
void subdomain_ids(std::set< subdomain_id_type > &ids, const bool global=true) const
Constructs a list of all subdomain identifiers in the local mesh if global == false, and in the global mesh if global == true (default).
Definition: mesh_base.C:959
std::set< Order > _elem_default_orders
We cache the (default) order of the geometric elements present in the mesh.
Definition: mesh_base.h:1984
bool allow_find_neighbors() const
Definition: mesh_base.h:1204
virtual Node * insert_node(Node *n)=0
This method is deprecated.
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
Definition: boundary_info.h:57
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:482
bool _skip_find_neighbors
If this is true then we will skip find_neighbors in prepare_for_use.
Definition: mesh_base.h:1955
virtual void delete_node(Node *n)=0
Removes the Node n from the mesh.
std::pair< std::vector< unsigned int >, std::vector< unsigned int > > merge_extra_integer_names(const MeshBase &other)
Merge extra-integer arrays from an other mesh.
Definition: mesh_base.C:1958
unsigned int n_elemsets() const
Returns the number of unique elemset ids which have been added via add_elemset_code(), which is the size of the _all_elemset_ids set.
Definition: mesh_base.C:424
Order _supported_nodal_order
We cache the maximum nodal order supported by all the mesh&#39;s elements (the minimum supported_nodal_or...
Definition: mesh_base.h:1990
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1977
unsigned int add_elem_datum(const std::string &name, bool allocate_data=true, const T *default_value=nullptr)
Register a datum (of type T) to be added to each element in the mesh.
Definition: mesh_base.h:2292
unsigned int get_node_integer_index(std::string_view name) const
Definition: mesh_base.C:715
std::string & subdomain_name(subdomain_id_type id)
Definition: mesh_base.C:1692
const std::set< unsigned char > & elem_dimensions() const
Definition: mesh_base.h:282
void allow_find_neighbors(bool allow)
If false is passed then this mesh will no longer work to find element neighbors when being prepared f...
Definition: mesh_base.h:1203
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
Definition: mesh_base.h:275
dof_id_type n_nodes_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:1023
variant_filter_iterator< MeshBase::Predicate, const Node *const, const Node *const &, const Node *const * > const_node_filter_iter
Definition: mesh_base.h:2180
virtual dof_id_type parallel_n_nodes() const =0
std::string get_local_constraints(bool print_nonlocal=false) const
Gets a string reporting all mesh constraint rows local to this processor.
Definition: mesh_base.C:2384
bool allow_remote_element_removal() const
Definition: mesh_base.h:1213
void size_node_extra_integers()
Size extra-integer arrays of all nodes in the mesh.
Definition: mesh_base.C:1949
An object whose state is distributed along a set of processors.
void prepare_for_use()
Definition: mesh_base.C:794
virtual dof_id_type parallel_n_elem() const =0
virtual void clear()
Deletes all the element and node data that is currently stored.
Definition: mesh_base.C:920
variant_filter_iterator< MeshBase::Predicate, Node *const, Node *const &, Node *const * > const_node_filter_iter
Definition: mesh_base.h:2154
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:1569
unsigned int add_node_datum(const std::string &name, bool allocate_data=true, const T *default_value=nullptr)
Register a datum (of type T) to be added to each node in the mesh.
Definition: mesh_base.h:2341
const DofMap &dof_map LIBMESH_COMMA unsigned int var_num
Definition: mesh_base.h:1644
virtual void write(const std::string &name) const =0
const std::set< subdomain_id_type > & get_mesh_subdomains() const
Definition: mesh_base.h:1814
bool skip_partitioning() const
Definition: mesh_base.h:1256
std::map< GhostingFunctor *, std::shared_ptr< GhostingFunctor > > _shared_functors
Hang on to references to any GhostingFunctor objects we were passed in shared_ptr form...
Definition: mesh_base.h:2092
unsigned int n_partitions() const
Definition: mesh_base.h:1345
virtual Node * add_node(Node *n)=0
Add Node n to the end of the vertex array.
virtual void clear_elems()=0
Deletes all the element data that is currently stored.
virtual const Elem * elem_ptr(const dof_id_type i) const =0
The definition of the node_iterator struct.
Definition: mesh_base.h:2247
ElemMappingType
Enumeration of possible element master->physical mapping types.
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:2274
virtual Elem * insert_elem(Elem *e)=0
Insert elem e to the element array, preserving its id and replacing/deleting any existing element wit...
std::vector< dof_id_type > _node_integer_default_values
The array of default initialization values for integer data associated with each node in the mesh...
Definition: mesh_base.h:2051
std::vector< unsigned int > add_elem_data(const std::vector< std::string > &names, bool allocate_data=true, const std::vector< T > *default_values=nullptr)
Register data (of type T) to be added to each element in the mesh.
Definition: mesh_base.h:2316
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:1618
std::set< GhostingFunctor * >::const_iterator ghosting_functors_begin() const
Beginning of range of ghosting functors.
Definition: mesh_base.h:1291
std::set< elemset_id_type > elemset_type
Typedef for the "set" container used to store elemset ids.
Definition: mesh_base.h:318
std::vector< dof_id_type > _elem_integer_default_values
The array of default initialization values for integer data associated with each element in the mesh...
Definition: mesh_base.h:2039
subdomain_id_type n_subdomains() const
Definition: mesh_base.C:997
std::string get_info(const unsigned int verbosity=0, const bool global=true) const
Definition: mesh_base.C:1082
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual bool contract()=0
Delete subactive (i.e.
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
virtual SimpleRange< element_iterator > active_local_subdomain_elements_ptr_range(subdomain_id_type sid)=0
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...
void post_dofobject_moves(MeshBase &&other_mesh)
Moves any superclass data (e.g.
Definition: mesh_base.C:1969
virtual void all_complete_order()
Calls the range-based version of this function with a range consisting of all elements in the mesh...
Definition: mesh_base.C:1613
unsigned int spatial_dimension() const
Definition: mesh_base.C:543
element_iterator(const IterType &d, const IterType &e, const PredType &p)
Definition: mesh_base.h:2203
std::map< const Node *, constraint_rows_mapped_type > constraint_rows_type
Definition: mesh_base.h:1698
OStreamProxy out
void print_constraint_rows(std::ostream &os=libMesh::out, bool print_nonlocal=false) const
Prints (from processor 0) all mesh constraint rows.
Definition: mesh_base.C:2356
virtual bool is_replicated() const
Definition: mesh_base.h:233
bool _is_prepared
Flag indicating if the mesh has been prepared for use.
Definition: mesh_base.h:1896
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:639
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:1678
The definition of the const_node_iterator struct.
Definition: mesh_base.h:2267
MeshBase(const Parallel::Communicator &comm_in, unsigned char dim=1)
Constructor.
Definition: mesh_base.C:59
void all_second_order(const bool full_ordered=true)
Calls the range-based version of this function with a range consisting of all elements in the mesh...
Definition: mesh_base.C:1608
dof_id_type n_active_sub_elem() const
Same as n_sub_elem(), but only counts active elements.
Definition: mesh_base.C:1070
virtual ~MeshBase()
Destructor.
Definition: mesh_base.C:363
void set_elem_dimensions(std::set< unsigned char > elem_dims)
Most of the time you should not need to call this, as the element dimensions will be set automaticall...
Definition: mesh_base.C:381
unsigned int mesh_dimension() const
Definition: mesh_base.C:372
unsigned int level ElemType type std::set< subdomain_id_type > ss processor_id_type pid unsigned int level std::set< subdomain_id_type > virtual ss SimpleRange< element_iterator > active_subdomain_elements_ptr_range(subdomain_id_type sid)=0
std::unique_ptr< GhostingFunctor > _default_ghosting
The default geometric GhostingFunctor, used to implement standard libMesh element ghosting behavior...
Definition: mesh_base.h:2077
void change_elemset_id(elemset_id_type old_id, elemset_id_type new_id)
Replace elemset id "old_id" with "new_id".
Definition: mesh_base.C:502
unsigned int add_node_integer(std::string name, bool allocate_data=true, dof_id_type default_value=DofObject::invalid_id)
Register an integer datum (of type dof_id_type) to be added to each node in the mesh.
Definition: mesh_base.C:649
variant_filter_iterator< MeshBase::Predicate, Elem *const, Elem *const &, Elem *const *, const Elem *const, const Elem *const &, const Elem *const * > elem_filter_iter
Definition: mesh_base.h:2162
virtual SimpleRange< element_iterator > active_subdomain_set_elements_ptr_range(std::set< subdomain_id_type > ss)=0
unique_id_type next_unique_id()
Definition: mesh_base.h:461
void set_default_mapping_data(const unsigned char data)
Set the default master space to physical space mapping basis functions to be used on newly added elem...
Definition: mesh_base.h:839
const std::string & get_node_integer_name(unsigned int i) const
Definition: mesh_base.h:1066
virtual void libmesh_assert_valid_parallel_ids() const
Verify id and processor_id consistency of our elements and nodes containers.
Definition: mesh_base.h:1516
virtual const Node & node_ref(const dof_id_type i) const
Definition: mesh_base.h:596
virtual const Point & point(const dof_id_type i) const =0
bool _skip_all_partitioning
If this is true then no partitioning should be done.
Definition: mesh_base.h:1943
const_node_iterator(const MeshBase::node_iterator &rhs)
The conversion-to-const ctor.
Definition: mesh_base.h:2285
bool allow_renumbering() const
Definition: mesh_base.h:1197
const constraint_rows_type & get_constraint_rows() const
Definition: mesh_base.h:1706
void cache_elem_dims()
Definition: mesh_base.C:1725
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:253
MeshBase & interior_mesh()
Definition: mesh_base.h:1802
const_element_iterator(const MeshBase::element_iterator &rhs)
The conversion-to-const ctor.
Definition: mesh_base.h:2234
virtual void update_post_partitioning()
Recalculate any cached data after elements and nodes have been repartitioned.
Definition: mesh_base.h:1177
virtual dof_id_type max_node_id() const =0
void reinit_ghosting_functors()
Loops over ghosting functors and calls mesh_reinit()
Definition: mesh_base.C:911
virtual dof_id_type n_elem() const =0
virtual const Node * node_ptr(const dof_id_type i) const =0
processor_id_type processor_id() const
std::unique_ptr< PointLocatorBase > _point_locator
A PointLocator class for this mesh.
Definition: mesh_base.h:1905
const DofMap &dof_map LIBMESH_COMMA unsigned int std::string & set_subdomain_name_map()
Definition: mesh_base.h:1692
virtual void redistribute()
Redistribute elements between processors.
Definition: mesh_base.C:985
Real _point_locator_close_to_point_tol
If nonzero, we will call PointLocatorBase::set_close_to_point_tol() on any PointLocators that we crea...
Definition: mesh_base.h:2110
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:1911
GhostingFunctor & default_ghosting()
Default ghosting functor.
Definition: mesh_base.h:1303
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39
virtual void reserve_elem(const dof_id_type ne)=0
Reserves space for a known number of elements.
uint8_t unique_id_type
Definition: id_types.h:86
bool locally_equals(const MeshBase &other_mesh) const
This behaves the same as operator==, but only for the local and ghosted aspects of the mesh; i...
Definition: mesh_base.C:236
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:1970
unsigned int & set_n_partitions()
Definition: mesh_base.h:1865
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:117
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...
virtual dof_id_type n_nodes() const =0
variant_filter_iterator< MeshBase::Predicate, Node *const, Node *const &, Node *const *, const Node *const, const Node *const &, const Node *const * > node_filter_iter
Definition: mesh_base.h:2175
void size_elem_extra_integers()
Size extra-integer arrays of all elements in the mesh.
Definition: mesh_base.C:1940
std::set< GhostingFunctor * >::const_iterator ghosting_functors_end() const
End of range of ghosting functors.
Definition: mesh_base.h:1297
void add_ghosting_functor(GhostingFunctor &ghosting_functor)
Adds a functor which can specify ghosting requirements for use on distributed meshes.
Definition: mesh_base.h:1267
uint8_t dof_id_type
Definition: id_types.h:67
MeshBase & operator=(const MeshBase &)=delete
Copy and move assignment are not allowed because MeshBase subclasses manually manage memory (Elems an...
void set_point_locator_close_to_point_tol(Real val)
Set value used by PointLocatorBase::close_to_point_tol().
Definition: mesh_base.C:1919