libMesh
Loading...
Searching...
No Matches
mesh_base.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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#include "libmesh/vector_value.h"
40
41namespace libMesh
42{
43// Forward declarations
44class BoundaryInfo;
45class Elem;
46class GhostingFunctor;
47class Node;
48class Point;
49class Partitioner;
50class PeriodicBoundary;
51class PeriodicBoundaries;
52
53template <typename T>
54class SparseMatrix;
55
56enum ElemType : int;
57enum ElemMappingType : unsigned char;
58
59template <class MT>
60class MeshInput;
61
62template <typename iterator_type, typename object_type>
63class StoredRange;
64
81{
82public:
83
89 MeshBase (const Parallel::Communicator & comm_in,
90 unsigned char dim=1);
91
95 MeshBase (const MeshBase & other_mesh);
96
102 MeshBase(MeshBase &&) = delete;
103
114 MeshBase & operator= (const MeshBase &) = delete;
115 MeshBase & operator= (MeshBase && other_mesh);
116
121 virtual MeshBase & assign(MeshBase && other_mesh) = 0;
122
136 bool operator== (const MeshBase & other_mesh) const;
137
138 bool operator!= (const MeshBase & other_mesh) const
139 {
140 return !(*this == other_mesh);
141 }
142
148 bool locally_equals (const MeshBase & other_mesh) const;
149
155 virtual std::unique_ptr<MeshBase> clone() const = 0;
156
160 virtual ~MeshBase ();
161
165 virtual std::unique_ptr<Partitioner> & partitioner() { return _partitioner; }
166
170 const BoundaryInfo & get_boundary_info() const { return *boundary_info; }
171
176
184 virtual void clear ();
185
197 virtual void clear_elems () = 0;
198
204 bool is_prepared () const;
205
211 struct Preparation;
212
214 { return _preparation; }
215
216#ifdef LIBMESH_ENABLE_DEPRECATED
229 { libmesh_deprecated(); _preparation = false; }
230#endif // LIBMESH_ENABLE_DEPRECATED
231
237 void unset_is_prepared();
238
248
259
272
283
295
309
320
332
342
352
357 virtual bool is_serial () const
358 { return true; }
359
364 virtual bool is_serial_on_zero () const
365 { return true; }
366
372 virtual void set_distributed ()
373 { libmesh_error(); }
374
379 virtual bool is_replicated () const
380 { return true; }
381
386 virtual void allgather () {}
387
392 virtual void gather_to_zero() {}
393
402
407
414 unsigned int mesh_dimension () const;
415
423 void set_mesh_dimension (unsigned char d)
424 { _elem_dims.clear(); _elem_dims.insert(d); }
425
430 const std::set<unsigned char> & elem_dimensions() const
431 { return _elem_dims; }
432
437 const std::set<Order> & elem_default_orders() const
438 { return _elem_default_orders; }
439
447
458 void set_elem_dimensions(std::set<unsigned char> elem_dims);
459
466 typedef std::set<elemset_id_type> elemset_type;
467
490
496 unsigned int n_elemsets() const;
497
504 void get_elemsets(dof_id_type elemset_code, MeshBase::elemset_type & id_set_to_fill) const;
506
511 std::vector<dof_id_type> get_elemset_codes() const;
512
519 void change_elemset_code(dof_id_type old_code, dof_id_type new_code);
520
526
553 unsigned int spatial_dimension () const;
554
559 void set_spatial_dimension(unsigned char d);
560
570 virtual dof_id_type n_nodes () const = 0;
571
581 virtual dof_id_type parallel_n_nodes () const = 0;
582
587
592 { return this->n_nodes_on_proc (this->processor_id()); }
593
599
604 virtual dof_id_type max_node_id () const = 0;
605
606#ifdef LIBMESH_ENABLE_UNIQUE_ID
611
621 virtual void set_next_unique_id(unique_id_type id) = 0;
622#endif
623
632 virtual void reserve_nodes (const dof_id_type nn) = 0;
633
641 virtual dof_id_type n_elem () const = 0;
642
650 virtual dof_id_type parallel_n_elem () const = 0;
651
656 virtual dof_id_type max_elem_id () const = 0;
657
662#ifdef LIBMESH_ENABLE_UNIQUE_ID
664#endif
665
674 virtual void reserve_elem (const dof_id_type ne) = 0;
675
680 virtual void update_parallel_id_counts () = 0;
681
687 virtual dof_id_type n_active_elem () const = 0;
688
693
698 { return this->n_elem_on_proc (this->processor_id()); }
699
705
710
715 { return this->n_active_elem_on_proc (this->processor_id()); }
716
726 dof_id_type n_sub_elem () const;
727
732
738 virtual const Point & point (const dof_id_type i) const = 0;
739
745 virtual const Node & node_ref (const dof_id_type i) const
746 {
747 return *this->node_ptr(i);
748 }
749
754 virtual Node & node_ref (const dof_id_type i)
755 {
756 return *this->node_ptr(i);
757 }
758
763 virtual const Node * node_ptr (const dof_id_type i) const = 0;
764
770 virtual Node * node_ptr (const dof_id_type i) = 0;
771
776 virtual const Node * query_node_ptr (const dof_id_type i) const = 0;
777
782 virtual Node * query_node_ptr (const dof_id_type i) = 0;
783
788 virtual const Elem & elem_ref (const dof_id_type i) const
789 {
790 return *this->elem_ptr(i);
791 }
792
798 virtual Elem & elem_ref (const dof_id_type i)
799 {
800 return *this->elem_ptr(i);
801 }
802
807 virtual const Elem * elem_ptr (const dof_id_type i) const = 0;
808
814 virtual Elem * elem_ptr (const dof_id_type i) = 0;
815
820 virtual const Elem * query_elem_ptr (const dof_id_type i) const = 0;
821
826 virtual Elem * query_elem_ptr (const dof_id_type i) = 0;
827
838 virtual Node * add_point (const Point & p,
840 const processor_id_type proc_id =
842
846 virtual Node * add_node (Node * n) = 0;
847
856 virtual Node * add_node (std::unique_ptr<Node> n) = 0;
857
861 virtual void delete_node (Node * n) = 0;
862
869 virtual void own_node (Node &) {}
870
876 virtual void renumber_node (dof_id_type old_id, dof_id_type new_id) = 0;
877
887 virtual Elem * add_elem (Elem * e) = 0;
888
897 virtual Elem * add_elem (std::unique_ptr<Elem> e) = 0;
898
906 virtual Elem * insert_elem (Elem * e) = 0;
907
916 virtual Elem * insert_elem (std::unique_ptr<Elem> e) = 0;
917
928 virtual void delete_elem (Elem * e) = 0;
929
935 virtual void renumber_elem (dof_id_type old_id, dof_id_type new_id) = 0;
936
945
951 {
953 }
954
959 unsigned char default_mapping_data () const
960 {
962 }
963
968 void set_default_mapping_data (const unsigned char data)
969 {
971 }
972
990 virtual void find_neighbors (const bool reset_remote_elements = false,
991 const bool reset_current_list = true,
992 const bool assert_valid = true) = 0;
993
998 void remove_orphaned_nodes ();
999
1005 virtual void renumber_nodes_and_elements () = 0;
1006
1014
1015
1016#ifdef LIBMESH_ENABLE_AMR
1022 virtual bool contract () = 0;
1023#endif
1024
1042 unsigned int add_elem_integer(std::string name,
1043 bool allocate_data = true,
1044 dof_id_type default_value = DofObject::invalid_id);
1045
1060 std::vector<unsigned int> add_elem_integers(const std::vector<std::string> & names,
1061 bool allocate_data = true,
1062 const std::vector<dof_id_type> * default_values = nullptr);
1063
1064 /*
1065 * \returns The index number for the named extra element integer
1066 * datum, which must have already been added.
1067 */
1068 unsigned int get_elem_integer_index(std::string_view name) const;
1069
1070 /*
1071 * \returns Whether or not the mesh has an element integer with its name.
1072 */
1073 bool has_elem_integer(std::string_view name) const;
1074
1075 /*
1076 * \returns The name for the indexed extra element integer
1077 * datum, which must have already been added.
1078 */
1079 const std::string & get_elem_integer_name(unsigned int i) const
1080 { return _elem_integer_names[i]; }
1081
1082 /*
1083 * \returns The number of extra element integers for which space is
1084 * being reserved on this mesh.
1085 *
1086 * If non-integer data has been associated, each datum of type T
1087 * counts for sizeof(T)/sizeof(dof_id_type) times in the return
1088 * value.
1089 */
1090 unsigned int n_elem_integers() const { return _elem_integer_names.size(); }
1091
1117 template <typename T>
1118 unsigned int add_elem_datum(const std::string & name,
1119 bool allocate_data = true,
1120 const T * default_value = nullptr);
1121
1142 template <typename T>
1143 std::vector<unsigned int> add_elem_data(const std::vector<std::string> & names,
1144 bool allocate_data = true,
1145 const std::vector<T> * default_values = nullptr);
1146
1164 unsigned int add_node_integer(std::string name,
1165 bool allocate_data = true,
1166 dof_id_type default_value = DofObject::invalid_id);
1167
1182 std::vector<unsigned int> add_node_integers(const std::vector<std::string> & names,
1183 bool allocate_data = true,
1184 const std::vector<dof_id_type> * default_values = nullptr);
1185
1186 /*
1187 * \returns The index number for the named extra node integer
1188 * datum, which must have already been added.
1189 */
1190 unsigned int get_node_integer_index(std::string_view name) const;
1191
1192 /*
1193 * \returns Whether or not the mesh has a node integer with its name.
1194 */
1195 bool has_node_integer(std::string_view name) const;
1196
1197 /*
1198 * \returns The name for the indexed extra node integer
1199 * datum, which must have already been added.
1200 */
1201 const std::string & get_node_integer_name(unsigned int i) const
1202 { return _node_integer_names[i]; }
1203
1204 /*
1205 * \returns The number of extra node integers for which space is
1206 * being reserved on this mesh.
1207 *
1208 * If non-integer data has been associated, each datum of type T
1209 * counts for sizeof(T)/sizeof(dof_id_type) times in the return
1210 * value.
1211 */
1212 unsigned int n_node_integers() const { return _node_integer_names.size(); }
1213
1239 template <typename T>
1240 unsigned int add_node_datum(const std::string & name,
1241 bool allocate_data = true,
1242 const T * default_value = nullptr);
1243
1264 template <typename T>
1265 std::vector<unsigned int> add_node_data(const std::vector<std::string> & name,
1266 bool allocate_data = true,
1267 const std::vector<T> * default_values = nullptr);
1268
1300#ifdef LIBMESH_ENABLE_DEPRECATED
1301 void prepare_for_use (const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors);
1302 void prepare_for_use (const bool skip_renumber_nodes_and_elements);
1303#endif // LIBMESH_ENABLE_DEPRECATED
1304 void prepare_for_use ();
1305
1306 /*
1307 * Prepare a newly created or modified mesh for use.
1308 *
1309 * Unlike \p prepare_for_use(), \p complete_preparation() performs
1310 * *only* those preparatory steps that have been marked as
1311 * necessary in the MeshBase::Preparation state.
1312 */
1313 void complete_preparation();
1314
1318 virtual void partition (const unsigned int n_parts);
1319
1321 { this->partition(this->n_processors()); }
1322
1329 virtual void redistribute ();
1330
1336 virtual void update_post_partitioning ();
1337
1357
1362 void allow_find_neighbors(bool allow) { _skip_find_neighbors = !allow; }
1364
1371
1380
1389
1413
1416
1417
1429 void skip_partitioning(bool skip) { _skip_all_partitioning = skip; }
1430
1432
1442 void add_ghosting_functor(GhostingFunctor & ghosting_functor);
1443
1452 void add_ghosting_functor(std::shared_ptr<GhostingFunctor> ghosting_functor)
1453 { _shared_functors[ghosting_functor.get()] = ghosting_functor;
1454 this->add_ghosting_functor(*ghosting_functor); }
1455
1460 void remove_ghosting_functor(GhostingFunctor & ghosting_functor);
1461
1467 typedef std::vector<GhostingFunctor *>::const_iterator GhostingFunctorIterator;
1468
1474
1480
1485
1498 void subdomain_ids (std::set<subdomain_id_type> & ids, const bool global = true) const;
1499
1508
1517
1526 unsigned int n_partitions () const
1527 { return _n_parts; }
1528
1545 std::string get_info (const unsigned int verbosity = 0, const bool global = true) const;
1546
1553 void print_info (std::ostream & os=libMesh::out, const unsigned int verbosity = 0, const bool global = true) const;
1554
1560 friend std::ostream & operator << (std::ostream & os, const MeshBase & m);
1561
1566 virtual void read (const std::string & name,
1567 void * mesh_data=nullptr,
1568 bool skip_renumber_nodes_and_elements=false,
1569 bool skip_find_neighbors=false,
1570 bool skip_detect_interior_parents=false) = 0;
1571 virtual void write (const std::string & name) const = 0;
1572
1579 virtual void all_first_order () = 0;
1580
1586
1594 struct element_iterator;
1596
1604 struct node_iterator;
1605 struct const_node_iterator;
1606
1619 const bool full_ordered = true) = 0;
1620
1625 void all_second_order (const bool full_ordered = true);
1626
1635
1640 virtual void all_complete_order ();
1641
1651 unsigned int recalculate_n_partitions();
1652
1660 std::unique_ptr<PointLocatorBase> sub_point_locator () const;
1661
1673
1677 void clear_point_locator ();
1678
1684 void set_count_lower_dim_elems_in_point_locator(bool count_lower_dim_elems);
1685
1690
1699
1700#ifdef LIBMESH_ENABLE_DEPRECATED
1707 std::string & subdomain_name(subdomain_id_type id);
1708#endif // LIBMESH_ENABLE_DEPRECATED
1709
1714 const std::string & subdomain_name(subdomain_id_type id) const;
1715
1724 const std::string & name,
1725 bool synchronous = false);
1726
1731 subdomain_id_type get_id_by_name(std::string_view name) const;
1732
1733 /*
1734 * We have many combinations of iterators that filter on various
1735 * characteristics; we use macros to make their abstract base class
1736 * and their subclass declarations more terse.
1737 */
1738#define ABSTRACT_ELEM_ITERATORS(TYPE, ARGDECL) \
1739 virtual element_iterator TYPE##elements_begin(ARGDECL) = 0; \
1740 virtual element_iterator TYPE##elements_end(ARGDECL) = 0; \
1741 virtual const_element_iterator TYPE##elements_begin(ARGDECL) const = 0; \
1742 virtual const_element_iterator TYPE##elements_end(ARGDECL) const = 0; \
1743 virtual SimpleRange<element_iterator> TYPE##element_ptr_range(ARGDECL) = 0; \
1744 virtual SimpleRange<const_element_iterator> TYPE##element_ptr_range(ARGDECL) const = 0;
1745
1746#define DECLARE_ELEM_ITERATORS(TYPE, ARGDECL, ARGS) \
1747 virtual element_iterator TYPE##elements_begin(ARGDECL) override final; \
1748 virtual element_iterator TYPE##elements_end(ARGDECL) override final; \
1749 virtual const_element_iterator TYPE##elements_begin(ARGDECL) const override final; \
1750 virtual const_element_iterator TYPE##elements_end(ARGDECL) const override final; \
1751 virtual SimpleRange<element_iterator> TYPE##element_ptr_range(ARGDECL) override final { return {TYPE##elements_begin(ARGS), TYPE##elements_end(ARGS)}; } \
1752 virtual SimpleRange<const_element_iterator> TYPE##element_ptr_range(ARGDECL) const override final { return {TYPE##elements_begin(ARGS), TYPE##elements_end(ARGS)}; }
1753
1754#define ABSTRACT_NODE_ITERATORS(TYPE, ARGDECL) \
1755 virtual node_iterator TYPE##nodes_begin(ARGDECL) = 0; \
1756 virtual node_iterator TYPE##nodes_end(ARGDECL) = 0; \
1757 virtual const_node_iterator TYPE##nodes_begin(ARGDECL) const = 0; \
1758 virtual const_node_iterator TYPE##nodes_end(ARGDECL) const = 0; \
1759 virtual SimpleRange<node_iterator> TYPE##node_ptr_range(ARGDECL) = 0; \
1760 virtual SimpleRange<const_node_iterator> TYPE##node_ptr_range(ARGDECL) const = 0;
1761
1762#define DECLARE_NODE_ITERATORS(TYPE, ARGDECL, ARGS) \
1763 virtual node_iterator TYPE##nodes_begin(ARGDECL) override final; \
1764 virtual node_iterator TYPE##nodes_end(ARGDECL) override final; \
1765 virtual const_node_iterator TYPE##nodes_begin(ARGDECL) const override final; \
1766 virtual const_node_iterator TYPE##nodes_end(ARGDECL) const override final; \
1767 virtual SimpleRange<node_iterator> TYPE##node_ptr_range(ARGDECL) override final { return {TYPE##nodes_begin(ARGS), TYPE##nodes_end(ARGS)}; } \
1768 virtual SimpleRange<const_node_iterator> TYPE##node_ptr_range(ARGDECL) const override final { return {TYPE##nodes_begin(ARGS), TYPE##nodes_end(ARGS)}; }
1769
1770#define LIBMESH_COMMA ,
1771
1772 /*
1773 * element_iterator accessors
1774 *
1775 * The basic elements_begin() and elements_end() iterators iterate
1776 * over all elements in a mesh, returning element pointers or const
1777 * element pointers when dereferenced (depending on whether the mesh
1778 * reference was const). range-for loops can be written using
1779 * element_ptr_range()
1780 *
1781 * Filtered versions of these iterators, which skip over all
1782 * elements not matching some predicate, are also available, by
1783 * adding a prefix to the methods above. E.g. local_ (in a form
1784 * like local_elements_begin() or local_element_ptr_range()) will
1785 * iterate only over elements whose processor_id() is the current
1786 * processor, or active_ will iterate only over active elements even
1787 * if the mesh is refined, or active_local_ will iterate over
1788 * elements that are both active and local. Negation forms such as
1789 * not_local_ also exist.
1790 *
1791 * For some iterator prefixes, such as type_, an argument is needed
1792 * for the filter; e.g. the ElemType to select for in that case.
1793 *
1794 * All valid prefixes and their corresponding arguments can be found
1795 * in the macro invocations below.
1796 */
1797 ABSTRACT_ELEM_ITERATORS(,) // elements_begin(), element_ptr_range(): all elements
1798 ABSTRACT_ELEM_ITERATORS(active_,) // Elem::active() == true
1799 ABSTRACT_ELEM_ITERATORS(ancestor_,) // Elem::ancestor() == true
1800 ABSTRACT_ELEM_ITERATORS(subactive_,) // Elem::subactive() == true
1801 ABSTRACT_ELEM_ITERATORS(local_,) // Elem::processor_id() == this processor
1802 ABSTRACT_ELEM_ITERATORS(unpartitioned_,) // Elem::processor_id() == invalid_processor_id
1803 ABSTRACT_ELEM_ITERATORS(facelocal_,) // is on or has a neighbor on this processor
1804 ABSTRACT_ELEM_ITERATORS(level_,unsigned int level) // Elem::level() == level
1805 ABSTRACT_ELEM_ITERATORS(pid_,processor_id_type pid) // Elem::processor_id() == pid
1806 ABSTRACT_ELEM_ITERATORS(type_,ElemType type) // Elem::type() == type
1807
1808 ABSTRACT_ELEM_ITERATORS(active_subdomain_,subdomain_id_type sid) // active && Elem::subdomain_id() == sid
1809 ABSTRACT_ELEM_ITERATORS(active_subdomain_set_,std::set<subdomain_id_type> ss) // active && ss.contains(Elem::subdomain_id())
1810
1811 // Iterators which use negations of filters described above
1813 ABSTRACT_ELEM_ITERATORS(not_ancestor_,)
1815 ABSTRACT_ELEM_ITERATORS(not_local_,)
1816 ABSTRACT_ELEM_ITERATORS(not_level_,unsigned int level)
1817
1818 // Iterators which combine multiple of the filters described above
1819 ABSTRACT_ELEM_ITERATORS(active_local_,)
1820 ABSTRACT_ELEM_ITERATORS(active_not_local_,)
1821 ABSTRACT_ELEM_ITERATORS(active_unpartitioned_,)
1824 ABSTRACT_ELEM_ITERATORS(local_level_,unsigned int level)
1825 ABSTRACT_ELEM_ITERATORS(local_not_level_,unsigned int level)
1826 ABSTRACT_ELEM_ITERATORS(active_local_subdomain_,subdomain_id_type sid)
1827 ABSTRACT_ELEM_ITERATORS(active_local_subdomain_set_,std::set<subdomain_id_type> ss)
1828
1829 // Backwards compatibility
1836
1837 // Discouraged from use - these iterators use outdated
1838 // pre-GhostingFunctor definitions and should be renamed if not
1839 // deprecated
1840 ABSTRACT_ELEM_ITERATORS(semilocal_,) // active && Elem::is_semilocal()
1841 ABSTRACT_ELEM_ITERATORS(ghost_,) // active && Elem::is_semilocal() && not local discouraged
1842 ABSTRACT_ELEM_ITERATORS(active_semilocal_,)
1843
1844 // solution can be evaluated, with the given DoF map, for the given
1845 // variable number, or for all variables by default
1846 ABSTRACT_ELEM_ITERATORS(evaluable_,const DofMap & dof_map LIBMESH_COMMA unsigned int var_num = libMesh::invalid_uint)
1847
1848 // solution can be evaluated for all variables of all given DoF maps
1849 ABSTRACT_ELEM_ITERATORS(multi_evaluable_,std::vector<const DofMap *> dof_maps)
1850
1851#ifdef LIBMESH_ENABLE_AMR
1852 ABSTRACT_ELEM_ITERATORS(flagged_,unsigned char rflag) // Elem::refinement_flag() == rflag
1853
1854 // Elem::refinement_flag() == rflag && Elem::processor_id() == pid
1855 ABSTRACT_ELEM_ITERATORS(flagged_pid_,unsigned char rflag LIBMESH_COMMA processor_id_type pid)
1856#endif
1857
1858 /*
1859 * node_iterator accessors
1860 *
1861 * The basic nodes_begin() and nodes_end() iterators iterate
1862 * over all nodes in a mesh, returning node pointers or const
1863 * node pointers when dereferenced (depending on whether the mesh
1864 * reference was const). range-for loops can be written using
1865 * node_ptr_range()
1866 *
1867 * Filtered versions of these iterators, which skip over all
1868 * nodes not matching some predicate, are also available, by
1869 * adding a prefix to the methods above. E.g. local_ (in a form
1870 * like local_nodes_begin() or local_node_ptr_range()) will
1871 * iterate only over nodes whose processor_id() is the current
1872 * processor.
1873 *
1874 * All valid prefixes and their corresponding arguments can be found
1875 * in the macro invocations below.
1876 */
1877 ABSTRACT_NODE_ITERATORS(,) // nodes_begin(), node_ptr_range(): all nodes
1878 ABSTRACT_NODE_ITERATORS(active_,) // Node::active() == true; i.e. Node::id() != invalid_id
1879 ABSTRACT_NODE_ITERATORS(local_,) // Node::processor_id() == this processor
1880 ABSTRACT_NODE_ITERATORS(bnd_,) // BoundaryInfo::n_boundary_ids(node) > 0
1881 ABSTRACT_NODE_ITERATORS(pid_,processor_id_type pid) // Node::processor_id() == pid
1882 ABSTRACT_NODE_ITERATORS(bid_,boundary_id_type bid) // BoundaryInfo::has_boundary_id(node, bid)
1883
1884 // solution can be evaluated, with the given DoF map, for the given
1885 // variable number, or for all variables by default
1886 ABSTRACT_NODE_ITERATORS(evaluable_,const DofMap & dof_map LIBMESH_COMMA unsigned int var_num = libMesh::invalid_uint)
1887
1888 // solution can be evaluated for all variables of all given DoF maps
1889 ABSTRACT_NODE_ITERATORS(multi_evaluable_,std::vector<const DofMap *> dof_maps)
1890
1891 // Technically these define libMesh::MeshBase::*ElemRange, but since
1892 // those don't conflict with libMesh::*ElemRange they're as good as
1893 // a real forward declaration, which we can't do here.
1896
1905
1914
1919 void clear_stored_ranges();
1920
1926 const std::map<subdomain_id_type, std::string> & get_subdomain_name_map () const
1927 { return _block_id_to_name; }
1928
1929 typedef std::vector<std::pair<std::pair<const Elem *, unsigned int>, Real>> constraint_rows_mapped_type;
1930 typedef std::map<const Node *, constraint_rows_mapped_type> constraint_rows_type;
1931
1937
1940
1942
1946 void copy_constraint_rows(const MeshBase & other_mesh);
1947
1975 template <typename T>
1976 void copy_constraint_rows(const SparseMatrix<T> & constraint_operator,
1977 bool precondition_constraint_operator = false);
1978
1985 void print_constraint_rows(std::ostream & os=libMesh::out,
1986 bool print_nonlocal=false) const;
1987
1993 std::string get_local_constraints(bool print_nonlocal=false) const;
1994
1995#ifdef LIBMESH_ENABLE_DEPRECATED
2003 void cache_elem_dims();
2004#endif // LIBMESH_ENABLE_DEPRECATED
2005
2006 /*
2007 * Search the mesh and cache data for the elements
2008 * present in the mesh. This is done in prepare_for_use(), but can
2009 * be done manually by other classes after major mesh modifications.
2010 * Data cached includes:
2011 * - elem dimensions
2012 * - elem subdomains
2013 */
2014 void cache_elem_data();
2015
2026
2032
2040 const MeshBase & interior_mesh() const { return *_interior_mesh; }
2041
2046
2050 void set_interior_mesh(MeshBase & int_mesh) { _interior_mesh = &int_mesh; }
2051
2057 const std::set<subdomain_id_type> & get_mesh_subdomains() const
2058 { libmesh_assert(this->is_prepared()); return _mesh_subdomains; }
2059
2060#ifdef LIBMESH_ENABLE_PERIODIC
2065 const boundary_id_type b2,
2066 const RealVectorValue & translation);
2067
2069
2071
2073 const boundary_id_type b2);
2074#endif
2075
2080 {
2084 Preparation();
2085
2089 explicit operator bool() const;
2090
2094 Preparation & operator= (bool set_all);
2095
2100 bool operator== (const Preparation & other) const;
2101 bool operator!= (const Preparation & other) const;
2102
2113 };
2114
2115protected:
2116
2117#ifdef LIBMESH_ENABLE_PERIODIC
2119 std::unique_ptr<PeriodicBoundaries> _disjoint_neighbor_boundary_pairs;
2120#endif
2121
2131 std::unique_ptr<BoundaryInfo> boundary_info;
2132
2141 void post_dofobject_moves(MeshBase && other_mesh);
2142
2147 void copy_cached_data (const MeshBase & other_mesh);
2148
2153 virtual bool subclass_locally_equals (const MeshBase & other_mesh) const = 0;
2154
2159 bool nodes_and_elements_equal(const MeshBase & other_mesh) const;
2160
2164 unsigned int & set_n_partitions ()
2165 { return _n_parts; }
2166
2177 unsigned int _n_parts;
2178
2184
2191
2196
2205 mutable std::unique_ptr<ElemRange> _element_stored_range;
2206
2215 mutable std::unique_ptr<ConstElemRange>
2217
2225 mutable std::unique_ptr<PointLocatorBase> _point_locator;
2226
2232
2239 std::unique_ptr<Partitioner> _partitioner;
2240
2241#ifdef LIBMESH_ENABLE_UNIQUE_ID
2246#endif
2247
2253
2259
2264
2271
2276
2281
2289
2302
2308 std::map<subdomain_id_type, std::string> _block_id_to_name;
2309
2315 std::set<unsigned char> _elem_dims;
2316
2322 std::set<Order> _elem_default_orders;
2323
2329
2333 std::set<subdomain_id_type> _mesh_subdomains;
2334
2357 std::map<dof_id_type, const MeshBase::elemset_type *> _elemset_codes;
2358 std::map<MeshBase::elemset_type, dof_id_type> _elemset_codes_inverse_map;
2360
2365 unsigned char _spatial_dimension;
2366
2371 std::vector<std::string> _elem_integer_names;
2372
2377 std::vector<dof_id_type> _elem_integer_default_values;
2378
2383 std::vector<std::string> _node_integer_names;
2384
2389 std::vector<dof_id_type> _node_integer_default_values;
2390
2395
2400
2407 std::pair<std::vector<unsigned int>, std::vector<unsigned int>>
2408 merge_extra_integer_names(const MeshBase & other);
2409
2415 std::unique_ptr<GhostingFunctor> _default_ghosting;
2416
2424 std::vector<GhostingFunctor *> _ghosting_functors;
2425
2430 std::map<GhostingFunctor *, std::shared_ptr<GhostingFunctor> > _shared_functors;
2431
2432 // Keep track of any constraint equations that are inherent to the
2433 // mesh, such as FE nodes whose Rational Bernstein values need to be
2434 // constrained in terms of values on spline control nodes.
2435 //
2436 // _constraint_rows[constrained_node][i].first.first is an
2437 // element (e.g. a NodeElem for a spline control node),
2438 // _constraint_rows[constrained_node][i].first.second is the
2439 // local node id of that element which is a constraining node,
2440 // _constraint_rows[constrained_node][i].second is that node's
2441 // constraint coefficient.
2443
2449
2454 friend class Partitioner;
2455
2460 friend class MeshInput<MeshBase>;
2461
2466 friend class BoundaryInfo;
2467
2472 friend class MeshCommunication;
2473
2474
2479#ifdef LIBMESH_ENABLE_DEPRECATED
2481
2483 Elem * const,
2484 Elem * const &,
2486
2488
2490 Node * const,
2491 Node * const &,
2493#else
2495 Elem * const,
2496 Elem * const &,
2497 Elem * const *,
2498 const Elem * const,
2499 const Elem * const &,
2500 const Elem * const *> elem_filter_iter;
2501
2503 const Elem * const,
2504 const Elem * const &,
2506
2508 Node * const,
2509 Node * const &,
2510 Node * const *,
2511 const Node * const,
2512 const Node * const &,
2513 const Node * const *> node_filter_iter;
2514
2516 const Node * const,
2517 const Node * const &,
2519#endif // LIBMESH_ENABLE_DEPRECATED
2520
2521};
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2536struct
2538{
2539 // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
2540 template <typename PredType, typename IterType>
2541 element_iterator (const IterType & d,
2542 const IterType & e,
2543 const PredType & p ) :
2544 elem_filter_iter(d,e,p) {}
2545};
2546
2547
2548
2549
2554struct
2556{
2560 template <typename PredType, typename IterType>
2561 const_element_iterator (const IterType & d,
2562 const IterType & e,
2563 const PredType & p ) :
2564 const_elem_filter_iter(d,e,p) {}
2565
2574};
2575
2576
2577
2578
2579
2580
2581
2585struct
2587{
2591 template <typename PredType, typename IterType>
2592 node_iterator (const IterType & d,
2593 const IterType & e,
2594 const PredType & p ) :
2595 node_filter_iter(d,e,p) {}
2596};
2597
2598
2599
2600
2605struct
2607{
2611 template <typename PredType, typename IterType>
2612 const_node_iterator (const IterType & d,
2613 const IterType & e,
2614 const PredType & p ) :
2615 const_node_filter_iter(d,e,p) {}
2616
2625};
2626
2627
2628template <typename T>
2629inline
2630unsigned int MeshBase::add_elem_datum(const std::string & name,
2631 bool allocate_data,
2632 const T * default_value)
2633{
2634 const std::size_t old_size = _elem_integer_names.size();
2635
2636 unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
2637 std::vector<dof_id_type> int_data(n_more_integers+1, DofObject::invalid_id);
2638 if (default_value)
2639 std::memcpy(int_data.data(), default_value, sizeof(T));
2640
2641 unsigned int start_idx = this->add_elem_integer(name, false, int_data[0]);
2642 for (unsigned int i=0; i != n_more_integers; ++i)
2643 this->add_elem_integer(name+"__"+std::to_string(i), false, int_data[i+1]);
2644
2645 if (allocate_data && old_size != _elem_integer_names.size())
2647
2648 return start_idx;
2649}
2650
2651
2652template <typename T>
2653inline
2654std::vector<unsigned int> MeshBase::add_elem_data(const std::vector<std::string> & names,
2655 bool allocate_data,
2656 const std::vector<T> * default_values)
2657{
2658 libmesh_assert(!default_values || default_values->size() == names.size());
2659
2660 std::vector<unsigned int> returnval(names.size());
2661
2662 const std::size_t old_size = _elem_integer_names.size();
2663
2664 for (auto i : index_range(names))
2665 returnval[i] =
2666 this->add_elem_datum<T>(names[i], false,
2667 default_values ?
2668 (*default_values)[i] : nullptr);
2669
2670 if (allocate_data && old_size != _elem_integer_names.size())
2672
2673 return returnval;
2674}
2675
2676
2677template <typename T>
2678inline
2679unsigned int MeshBase::add_node_datum(const std::string & name,
2680 bool allocate_data,
2681 const T * default_value)
2682{
2683 const std::size_t old_size = _node_integer_names.size();
2684
2685 unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
2686 std::vector<dof_id_type> int_data(n_more_integers+1, DofObject::invalid_id);
2687 if (default_value)
2688 std::memcpy(int_data.data(), default_value, sizeof(T));
2689
2690 unsigned int start_idx = this->add_node_integer(name, false, int_data[0]);
2691 for (unsigned int i=0; i != n_more_integers; ++i)
2692 this->add_node_integer(name+"__"+std::to_string(i), false, int_data[i+1]);
2693
2694 if (allocate_data && old_size != _node_integer_names.size())
2696
2697 return start_idx;
2698}
2699
2700
2701template <typename T>
2702inline
2703std::vector<unsigned int> MeshBase::add_node_data(const std::vector<std::string> & names,
2704 bool allocate_data,
2705 const std::vector<T> * default_values)
2706{
2707 libmesh_assert(!default_values || default_values->size() == names.size());
2708
2709 std::vector<unsigned int> returnval(names.size());
2710
2711 const std::size_t old_size = _node_integer_names.size();
2712
2713 for (auto i : index_range(names))
2714 returnval[i] =
2715 this->add_node_datum<T>(names[i], false,
2716 default_values ?
2717 (*default_values)[i] : nullptr);
2718
2719 if (allocate_data && old_size != _node_integer_names.size())
2721
2722 return returnval;
2723}
2724
2725
2726
2727} // namespace libMesh
2728
2729#endif // LIBMESH_MESH_BASE_H
unsigned int dim
void ErrorVector unsigned int
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
This class handles the numbering of degrees of freedom on a mesh.
Definition dof_map.h:181
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition dof_object.h:473
static constexpr 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:484
This is the base class from which all geometric element types are derived.
Definition elem.h:96
This abstract base class defines the interface by which library code and user code can report associa...
This is the MeshBase class.
Definition mesh_base.h:81
void set_subdomain_name(subdomain_id_type id, const std::string &name, bool synchronous=false)
Sets the name for the provided id.
Definition mesh_base.C:1914
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:1378
void set_isnt_prepared()
Tells this we have done some operation where we should no longer consider ourself prepared.
Definition mesh_base.h:228
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:2500
virtual const Node & node_ref(const dof_id_type i) const
Definition mesh_base.h:745
virtual const Point & point(const dof_id_type i) const =0
void unset_has_reinit_ghosting_functors()
Tells this we have done some operation (e.g.
Definition mesh_base.h:330
virtual bool is_serial() const
Definition mesh_base.h:357
void size_elem_extra_integers()
Size extra-integer arrays of all elements in the mesh.
Definition mesh_base.C:2361
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:968
virtual dof_id_type parallel_n_elem() const =0
virtual bool contract()=0
Delete subactive (i.e.
unsigned int n_elem_integers() const
Definition mesh_base.h:1090
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition mesh_base.h:170
void set_spatial_dimension(unsigned char d)
Sets the "spatial dimension" of the Mesh.
Definition mesh_base.C:613
virtual Elem & elem_ref(const dof_id_type i)
Definition mesh_base.h:798
Preparation preparation() const
Definition mesh_base.h:213
bool is_prepared() const
Definition mesh_base.C:1064
virtual std::unique_ptr< Partitioner > & partitioner()
A partitioner to use at each partitioning.
Definition mesh_base.h:165
bool allow_renumbering() const
Definition mesh_base.h:1356
virtual const Node * node_ptr(const dof_id_type i) const =0
MeshBase::elemset_type _all_elemset_ids
Definition mesh_base.h:2359
unsigned int mesh_dimension() const
Definition mesh_base.C:430
bool _allow_node_and_elem_unique_id_overlap
The Exodus reader (and potentially other readers in the future?) now supports setting Node and Elem u...
Definition mesh_base.h:2301
variant_filter_iterator< MeshBase::Predicate, const Node *const, const Node *const &, const Node *const * > const_node_filter_iter
Definition mesh_base.h:2518
virtual Node * query_node_ptr(const dof_id_type i)=0
virtual dof_id_type n_elem() const =0
virtual void all_first_order()=0
Converts a mesh with higher-order elements into a mesh with linear elements.
virtual bool is_replicated() const
Definition mesh_base.h:379
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:2703
void complete_preparation()
Definition mesh_base.C:874
bool _skip_detect_interior_parents
If this is true then we will skip detect_interior_parents in prepare_for_use.
Definition mesh_base.h:2280
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:271
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:439
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:869
virtual Elem * insert_elem(Elem *e)=0
Insert elem e to the element array, preserving its id and replacing/deleting any existing element wit...
const std::set< unsigned char > & elem_dimensions() const
Definition mesh_base.h:430
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:2783
bool skip_partitioning() const
Definition mesh_base.h:1431
Order supported_nodal_order() const
Definition mesh_base.h:445
Order _supported_nodal_order
We cache the maximum nodal order supported by all the mesh's elements (the minimum supported_nodal_or...
Definition mesh_base.h:2328
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 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,...
Definition mesh_base.C:1126
virtual Node * node_ptr(const dof_id_type i)=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:1813
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...
void set_point_locator_close_to_point_tol(Real val)
Set value used by PointLocatorBase::close_to_point_tol().
Definition mesh_base.C:2340
dof_id_type n_active_elem_on_proc(const processor_id_type proc) const
Definition mesh_base.C:1242
bool has_node_integer(std::string_view name) const
Definition mesh_base.C:790
virtual SimpleRange< element_iterator > active_subdomain_set_elements_ptr_range(std::set< subdomain_id_type > ss)=0
bool allow_detect_interior_parents() const
Definition mesh_base.h:1370
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:1362
unsigned int spatial_dimension() const
Definition mesh_base.C:606
PeriodicBoundaries * get_disjoint_neighbor_boundary_pairs()
Definition mesh_base.C:2296
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:565
unsigned int get_elem_integer_index(std::string_view name) const
Definition mesh_base.C:689
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:1355
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
Definition mesh_base.h:1926
subdomain_id_type n_local_subdomains() const
Definition mesh_base.C:1204
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:1803
virtual void delete_node(Node *n)=0
Removes the Node n from the mesh.
unsigned int get_node_integer_index(std::string_view name) const
Definition mesh_base.C:778
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:2357
bool allow_node_and_elem_unique_id_overlap() const
Definition mesh_base.h:1388
dof_id_type get_elemset_code(const MeshBase::elemset_type &id_set) const
Definition mesh_base.C:497
void unset_has_neighbor_ptrs()
Tells this we have done some operation (e.g.
Definition mesh_base.h:270
dof_id_type n_sub_elem() const
Definition mesh_base.C:1251
const ConstElemRange & active_local_element_stored_range() const
Definition mesh_base.C:1954
virtual void redistribute()
Redistribute elements between processors.
Definition mesh_base.C:1168
const ElemRange & element_stored_range()
Definition mesh_base.C:1939
const DofMap &dof_map LIBMESH_COMMA unsigned int var_num
Definition mesh_base.h:1846
std::unique_ptr< PeriodicBoundaries > _disjoint_neighbor_boundary_pairs
The disjoint neighbor boundary id pairs.
Definition mesh_base.h:2119
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:735
unsigned char _spatial_dimension
The "spatial dimension" of the Mesh.
Definition mesh_base.h:2365
virtual ~MeshBase()
Destructor.
Definition mesh_base.C:421
std::map< MeshBase::elemset_type, dof_id_type > _elemset_codes_inverse_map
Definition mesh_base.h:2358
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:2231
virtual void write(const std::string &name) const =0
dof_id_type n_active_sub_elem() const
Same as n_sub_elem(), but only counts active elements.
Definition mesh_base.C:1263
virtual SimpleRange< element_iterator > active_local_subdomain_elements_ptr_range(subdomain_id_type sid)=0
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:2288
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:712
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:512
void unset_has_boundary_id_sets()
Tells this we have done some operation which may have invalidated our cached boundary id sets.
Definition mesh_base.h:340
virtual std::unique_ptr< MeshBase > clone() const =0
Virtual "copy constructor".
const std::string & get_node_integer_name(unsigned int i) const
Definition mesh_base.h:1201
std::vector< dof_id_type > get_elemset_codes() const
Return a vector of all elemset codes defined on the mesh.
Definition mesh_base.C:503
virtual dof_id_type n_nodes() const =0
virtual void delete_elem(Elem *e)=0
Removes element e from the mesh.
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:941
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:2389
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false, bool skip_detect_interior_parents=false)=0
Interfaces for reading/writing a mesh to/from a file.
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition mesh_base.h:2245
bool _skip_renumber_nodes_and_elements
If this is true then renumbering will be kept to a minimum.
Definition mesh_base.h:2270
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:1100
virtual const Node * query_node_ptr(const dof_id_type i) const =0
std::vector< std::pair< std::pair< const Elem *, unsigned int >, Real > > constraint_rows_mapped_type
Definition mesh_base.h:1929
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
Definition mesh_base.h:423
virtual void all_second_order_range(const SimpleRange< element_iterator > &range, const bool full_ordered=true)=0
Converts a set of this Mesh's elements defined by range from FIRST order to SECOND order.
GhostingFunctorIterator ghosting_functors_begin() const
Beginning of range of ghosting functors.
Definition mesh_base.h:1472
void unset_has_synched_subdomain_name_map()
Tells this we have done some operation which may have left the subdomain id to name map inconsistent ...
Definition mesh_base.h:350
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:2430
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.
std::set< subdomain_id_type > _mesh_subdomains
We cache the subdomain ids of the elements present in the mesh.
Definition mesh_base.h:2333
dof_id_type n_unpartitioned_elem() const
Definition mesh_base.h:703
virtual void update_post_partitioning()
Recalculate any cached data (or invalidate any caches that are computed on the fly) after elements an...
Definition mesh_base.C:1180
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:1880
std::unique_ptr< PointLocatorBase > _point_locator
A PointLocator class for this mesh.
Definition mesh_base.h:2225
virtual const Elem * elem_ptr(const dof_id_type i) const =0
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:2654
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 ...
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:623
bool _skip_all_partitioning
If this is true then no partitioning should be done.
Definition mesh_base.h:2263
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,...
ABSTRACT_ELEM_ITERATORS(,) ABSTRACT_ELEM_ITERATORS(active_
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:2371
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
void prepare_for_use()
Definition mesh_base.C:860
void unset_has_synched_id_counts()
Tells this we have done some operation (e.g.
Definition mesh_base.h:257
void unset_has_removed_orphaned_nodes()
Tells this we have done some operation (e.g.
Definition mesh_base.h:318
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:2513
const constraint_rows_type & get_constraint_rows() const
Definition mesh_base.h:1938
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:2377
void unset_is_partitioned()
Tells this we have done some operation creating unpartitioned elements.
Definition mesh_base.h:246
void remove_orphaned_nodes()
Removes any orphaned nodes, nodes not connected to any elements.
Definition mesh_base.C:801
Real get_point_locator_close_to_point_tol() const
Definition mesh_base.C:2354
variant_filter_iterator< MeshBase::Predicate, const Elem *const, const Elem *const &, const Elem *const * > const_elem_filter_iter
Definition mesh_base.h:2505
unsigned int n_partitions() const
Definition mesh_base.h:1526
virtual void set_next_unique_id(unique_id_type id)=0
Sets the next available unique id to be used.
virtual Node * add_node(Node *n)=0
Add Node n to the end of the vertex array.
bool has_elem_integer(std::string_view name) const
Definition mesh_base.C:701
virtual Node * add_node(std::unique_ptr< Node > n)=0
Version of add_node() taking a std::unique_ptr by value.
dof_id_type n_local_elem() const
Definition mesh_base.h:697
dof_id_type n_unpartitioned_nodes() const
Definition mesh_base.h:597
virtual dof_id_type max_elem_id() const =0
void unset_has_interior_parent_ptrs()
Tells this we have done some operation (e.g.
Definition mesh_base.h:293
const std::string & get_elem_integer_name(unsigned int i) const
Definition mesh_base.h:1079
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:2258
virtual void allgather()
Gathers all elements and nodes of the mesh onto every processor.
Definition mesh_base.h:386
bool _skip_find_neighbors
If this is true then we will skip find_neighbors in prepare_for_use.
Definition mesh_base.h:2275
void unset_has_cached_elem_data()
Tells this we have done some operation (e.g.
Definition mesh_base.h:281
dof_id_type n_elem_on_proc(const processor_id_type proc) const
Definition mesh_base.C:1229
virtual Elem * insert_elem(std::unique_ptr< Elem > e)=0
Version of insert_elem() taking a std::unique_ptr by value.
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:399
MeshBase & operator=(const MeshBase &)=delete
Copy and move assignment are not allowed because MeshBase subclasses manually manage memory (Elems an...
ElemMappingType _default_mapping_type
The default mapping type (typically Lagrange) between master and physical space to assign to newly ad...
Definition mesh_base.h:2183
std::unique_ptr< BoundaryInfo > boundary_info
This class holds the boundary information.
Definition mesh_base.h:2131
std::set< Order > _elem_default_orders
We cache the (default) order of the geometric elements present in the mesh.
Definition mesh_base.h:2322
virtual void clear_elems()=0
Deletes all the element data that is currently stored.
const std::set< subdomain_id_type > & get_mesh_subdomains() const
Definition mesh_base.h:2057
bool skip_noncritical_partitioning() const
Definition mesh_base.h:1414
MeshBase * _interior_mesh
Defaulting to this, a pointer to the mesh used to generate boundary elements on this.
Definition mesh_base.h:2252
variant_filter_iterator< MeshBase::Predicate, Elem *const, Elem *const &, Elem *const * > const_elem_filter_iter
Definition mesh_base.h:2485
virtual void set_distributed()
Asserts that not all elements and nodes of the mesh necessarily exist on the current processor.
Definition mesh_base.h:372
std::vector< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition mesh_base.h:2424
virtual void clear()
Deletes all the element and node data that is currently stored.
Definition mesh_base.C:1036
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:2385
dof_id_type n_local_nodes() const
Definition mesh_base.h:591
std::unique_ptr< ConstElemRange > _const_active_local_element_stored_range
A cached ConstElemRange for threaded calculation on all local elements of this mesh.
Definition mesh_base.h:2216
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:2308
const std::set< Order > & elem_default_orders() const
Definition mesh_base.h:437
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:950
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.
constraint_rows_type _constraint_rows
Definition mesh_base.h:2442
virtual Elem * add_elem(std::unique_ptr< Elem > e)=0
Version of add_elem() taking a std::unique_ptr by value.
std::unique_ptr< Partitioner > _partitioner
A partitioner to use at each prepare_for_use().
Definition mesh_base.h:2239
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:2679
unsigned int n_elemsets() const
Returns the number of unique elemset ids which have been added via add_elemset_code(),...
Definition mesh_base.C:482
constraint_rows_type & get_constraint_rows()
Constraint rows accessors.
Definition mesh_base.h:1935
GhostingFunctor & default_ghosting()
Default ghosting functor.
Definition mesh_base.h:1484
const MeshBase & interior_mesh() const
Definition mesh_base.h:2040
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:1762
std::unique_ptr< GhostingFunctor > _default_ghosting
The default geometric GhostingFunctor, used to implement standard libMesh element ghosting behavior.
Definition mesh_base.h:2415
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:456
void unset_has_removed_remote_elements()
Tells this we have done some operation (e.g.
Definition mesh_base.h:307
unsigned int n_node_integers() const
Definition mesh_base.h:1212
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:2190
virtual void fix_broken_node_and_element_numbering()=0
There is no reason for a user to ever call this function.
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
dof_id_type n_constraint_rows() const
Definition mesh_base.C:2471
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:1808
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
BoundaryInfo & get_boundary_info()
Writable information about boundary ids on the mesh.
Definition mesh_base.h:175
dof_id_type n_active_local_elem() const
Definition mesh_base.h:714
bool allow_remote_element_removal() const
Definition mesh_base.h:1379
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:2448
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:1452
dof_id_type n_nodes_on_proc(const processor_id_type proc) const
Definition mesh_base.C:1216
variant_filter_iterator< MeshBase::Predicate, Node * > node_filter_iter
Definition mesh_base.h:2487
virtual Elem * elem_ptr(const dof_id_type i)=0
std::string & subdomain_name(subdomain_id_type id)
Definition mesh_base.C:1887
bool allow_find_neighbors() const
Definition mesh_base.h:1363
virtual Elem * query_elem_ptr(const dof_id_type i)=0
void sync_subdomain_name_map()
libMesh often expects all processors to know about names of all subdomain ids, but distributed mesh g...
Definition mesh_base.C:2066
virtual const Elem & elem_ref(const dof_id_type i) const
Definition mesh_base.h:788
void allow_node_and_elem_unique_id_overlap(bool allow)
If true is passed, then this mesh will no longer require unique_ids to be unique across the set of al...
Definition mesh_base.h:1387
void size_node_extra_integers()
Size extra-integer arrays of all nodes in the mesh.
Definition mesh_base.C:2376
unsigned int _n_parts
The number of partitions the mesh has.
Definition mesh_base.h:2177
std::map< const Node *, constraint_rows_mapped_type > constraint_rows_type
Definition mesh_base.h:1930
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:487
unsigned char default_mapping_data() const
Returns any default data value used by the master space to physical space mapping.
Definition mesh_base.h:959
void remove_disjoint_boundary_pair(const boundary_id_type b1, const boundary_id_type b2)
Definition mesh_base.C:2306
bool operator!=(const MeshBase &other_mesh) const
Definition mesh_base.h:138
void clear_point_locator()
Releases the current PointLocator object.
Definition mesh_base.C:1866
virtual void reserve_elem(const dof_id_type ne)=0
Reserves space for a known number of elements.
virtual void gather_to_zero()
Gathers all elements and nodes of the mesh onto processor zero.
Definition mesh_base.h:392
GhostingFunctorIterator ghosting_functors_end() const
End of range of ghosting functors.
Definition mesh_base.h:1478
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:1873
void add_ghosting_functor(GhostingFunctor &ghosting_functor)
Adds a functor which can specify ghosting requirements for use on distributed meshes.
Definition mesh_base.C:1078
void copy_constraint_rows(const MeshBase &other_mesh)
Copy the constraints from the other mesh to this mesh.
Definition mesh_base.C:2490
std::set< elemset_id_type > elemset_type
Typedef for the "set" container used to store elemset ids.
Definition mesh_base.h:466
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition mesh_base.h:2315
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,...
Definition mesh_base.C:646
std::vector< GhostingFunctor * >::const_iterator GhostingFunctorIterator
Iterator type for ghosting functor ranges.
Definition mesh_base.h:1467
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:2383
std::unique_ptr< PointLocatorBase > sub_point_locator() const
Definition mesh_base.C:1833
virtual void libmesh_assert_valid_parallel_ids() const
Verify id and processor_id consistency of our elements and nodes containers.
Definition mesh_base.h:1698
MeshBase(MeshBase &&)=delete
Move-constructor - deleted because after a theoretical move-construction and then destruction of the ...
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:1585
void add_disjoint_neighbor_boundary_pairs(const boundary_id_type b1, const boundary_id_type b2, const RealVectorValue &translation)
Register a pair of boundaries as disjoint neighbor boundary pairs.
Definition mesh_base.C:2272
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:2630
variant_filter_iterator< MeshBase::Predicate, Elem * > elem_filter_iter
The original iterator classes weren't properly const-safe; relying on their const-incorrectness is no...
Definition mesh_base.h:2480
std::map< subdomain_id_type, std::string > & set_subdomain_name_map()
Definition mesh_base.h:1924
unique_id_type next_unique_id() const
Definition mesh_base.h:610
subdomain_id_type get_id_by_name(std::string_view name) const
Definition mesh_base.C:1926
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:1755
virtual void update_parallel_id_counts()=0
Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors.
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:281
MeshBase & interior_mesh()
Definition mesh_base.h:2045
virtual dof_id_type n_active_elem() const =0
void reinit_ghosting_functors()
Loops over ghosting functors and calls mesh_reinit()
Definition mesh_base.C:1025
Preparation _preparation
Flags indicating in what ways this mesh has been prepared.
Definition mesh_base.h:2195
virtual MeshBase & assign(MeshBase &&other_mesh)=0
Shim to allow operator = (&&) to behave like a virtual function without having to be one.
void skip_partitioning(bool skip)
If true is passed in then nothing on this mesh will be (re)partitioned.
Definition mesh_base.h:1429
void set_interior_mesh(MeshBase &int_mesh)
Sets the interior mesh.
Definition mesh_base.h:2050
subdomain_id_type n_subdomains() const
Definition mesh_base.C:1190
virtual bool is_serial_on_zero() const
Definition mesh_base.h:364
std::string get_info(const unsigned int verbosity=0, const bool global=true) const
Definition mesh_base.C:1275
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:2811
virtual Node & node_ref(const dof_id_type i)
Definition mesh_base.h:754
void allow_detect_interior_parents(bool allow)
If false is passed then this mesh will no longer work to detect interior parents when being prepared ...
Definition mesh_base.h:1369
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:2441
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:2431
virtual void reserve_nodes(const dof_id_type nn)=0
Reserves space for a known number of nodes.
void skip_noncritical_partitioning(bool skip)
If true is passed in then the elements on this mesh will no longer be (re)partitioned,...
Definition mesh_base.h:1411
void unset_is_prepared()
Tells this we have done some operation where we should no longer consider ourself prepared.
Definition mesh_base.C:1070
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true, const bool assert_valid=true)=0
Locate element face (edge in 2D) neighbors.
void post_dofobject_moves(MeshBase &&other_mesh)
Moves any superclass data (e.g.
Definition mesh_base.C:2396
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:2077
unsigned int & set_n_partitions()
Definition mesh_base.h:2164
void clear_stored_ranges()
Clears stored ranges, to indicate that the mesh has changed and they should be regenerated when next ...
Definition mesh_base.C:1969
virtual dof_id_type parallel_n_nodes() const =0
variant_filter_iterator< MeshBase::Predicate, Node *const, Node *const &, Node *const * > const_node_filter_iter
Definition mesh_base.h:2492
virtual unique_id_type parallel_max_unique_id() const =0
std::unique_ptr< ElemRange > _element_stored_range
A cached ElemRange for threaded mutation of all semilocal elements of this mesh.
Definition mesh_base.h:2205
This is the MeshCommunication class.
This class defines an abstract interface for Mesh input.
Definition mesh_input.h:49
A Node is like a Point, but with more information.
Definition node.h:55
An object whose state is distributed along a set of processors.
processor_id_type processor_id() const
processor_id_type n_processors() const
The Partitioner class provides a uniform interface for partitioning algorithms.
Definition partitioner.h:52
We're using a class instead of a typedef to allow forward declarations and future flexibility.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
The SimpleRange templated class is intended to make it easy to construct ranges from pairs of iterato...
Generic sparse matrix.
The StoredRange class defines a contiguous, divisible set of objects.
Original Authors: Corwin Joy * Michael Gradman cjoy@houston.rr.com * Michael.Gradman@caminus....
The libMesh namespace provides an interface to certain functionality in the library.
uint8_t unique_id_type
Definition id_types.h:86
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:153
ElemType
Defines an enum for geometric element types.
int8_t boundary_id_type
Definition id_types.h:51
ElemMappingType
Enumeration of possible element master->physical mapping types.
libmesh_assert(ctx)
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:303
OStreamProxy out
uint8_t dof_id_type
Definition id_types.h:67
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type
Definition id_types.h:104
Flags indicating in what ways a mesh has been prepared for use.
Definition mesh_base.h:2080
bool operator!=(const Preparation &other) const
Definition mesh_base.C:2915
Preparation & operator=(bool set_all)
Set all flags to the "set_all" value.
Definition mesh_base.C:2871
bool operator==(const Preparation &other) const
Two Preparation objects are equivalent iff all the flags match, regardless of the true/false status o...
Definition mesh_base.C:2888
The definition of the const_element_iterator struct.
Definition mesh_base.h:2556
const_element_iterator(const MeshBase::element_iterator &rhs)
The conversion-to-const ctor.
Definition mesh_base.h:2572
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:2561
The definition of the const_node_iterator struct.
Definition mesh_base.h:2607
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:2612
const_node_iterator(const MeshBase::node_iterator &rhs)
The conversion-to-const ctor.
Definition mesh_base.h:2623
The definition of the element_iterator struct.
Definition mesh_base.h:2538
element_iterator(const IterType &d, const IterType &e, const PredType &p)
Definition mesh_base.h:2541
The definition of the node_iterator struct.
Definition mesh_base.h:2587
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:2592