libMesh
dof_object.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_DOF_OBJECT_H
21 #define LIBMESH_DOF_OBJECT_H
22 
23 // Local includes
24 #include "libmesh/id_types.h"
25 #include "libmesh/int_range.h"
26 #include "libmesh/libmesh_config.h"
27 #include "libmesh/libmesh_common.h"
28 #include "libmesh/libmesh.h" // libMesh::invalid_uint
29 #include "libmesh/reference_counted_object.h"
30 
31 // C++ includes
32 #include <cstddef>
33 #include <cstring>
34 #include <vector>
35 #include <memory>
36 
37 namespace libMesh
38 {
39 
40 // Forward declarations
41 class DofObject;
42 
43 
54 class DofObject : public ReferenceCountedObject<DofObject>
55 {
56 #ifdef LIBMESH_IS_UNIT_TESTING
57 public:
58 #else
59 protected:
60 #endif
61 
66  DofObject ();
67 
68 public:
69 
73  ~DofObject () = default;
74 
75 #ifdef LIBMESH_ENABLE_AMR
76 
85 #ifndef LIBMESH_ENABLE_DEPRECATED
86 protected:
87 #endif
88  std::unique_ptr<DofObject> old_dof_object;
89 
90 public:
97  const DofObject * get_old_dof_object() const { return old_dof_object.get(); }
98 
105  {
107  return *old_dof_object;
108  }
109 
111  {
113  return *old_dof_object;
114  }
115 
119  void clear_old_dof_object ();
120 
124  void set_old_dof_object ();
125 
126 #endif
127 
135  void clear_dofs ();
136 
140  void invalidate_dofs (const unsigned int sys_num = libMesh::invalid_uint);
141 
145  void invalidate_id ();
146 
150  void invalidate_processor_id ();
151 
155  void invalidate ();
156 
165  unsigned int n_dofs (const unsigned int s,
166  const unsigned int var =
167  libMesh::invalid_uint) const;
168 
172  dof_id_type id () const;
173 
177  dof_id_type & set_id ();
178 
182  unique_id_type unique_id () const;
183 
184 #ifdef LIBMESH_ENABLE_DEPRECATED
185 
191 #endif // LIBMESH_ENABLE_DEPRECATED
192 
196  void set_unique_id (unique_id_type new_id);
197 
201  void set_id (const dof_id_type dofid)
202  { this->set_id() = dofid; }
203 
208  bool valid_id () const;
209 
214  bool valid_unique_id () const;
215 
224 
230 
234  void processor_id (const processor_id_type pid);
235 
240  bool valid_processor_id () const;
241 
246  unsigned int n_systems() const;
247 
253  unsigned int n_pseudo_systems() const;
254 
263  void set_n_systems (const unsigned int s);
264 
270  void set_extra_integer (const unsigned int index, const dof_id_type value);
271 
277  dof_id_type get_extra_integer (const unsigned int index) const;
278 
285  template <typename T>
286  void set_extra_datum (const unsigned int index, const T value);
287 
294  template <typename T>
295  T get_extra_datum (const unsigned int index) const;
296 
297 
301  void add_system ();
302 
307  unsigned int n_var_groups(const unsigned int s) const;
308 
313  unsigned int n_vars(const unsigned int s,
314  const unsigned int vg) const;
315 
320  unsigned int n_vars(const unsigned int s) const;
321 
329  void set_n_vars_per_group(const unsigned int s,
330  const std::vector<unsigned int> & nvpg);
331 
341  unsigned int n_comp(const unsigned int s,
342  const unsigned int var) const;
343 
353  unsigned int n_comp_group(const unsigned int s,
354  const unsigned int vg) const;
355 
360  void set_n_comp(const unsigned int s,
361  const unsigned int var,
362  const unsigned int ncomp);
363 
368  void set_n_comp_group(const unsigned int s,
369  const unsigned int vg,
370  const unsigned int ncomp);
371 
380  dof_id_type dof_number(const unsigned int s,
381  const unsigned int var,
382  const unsigned int comp) const;
383 
392  dof_id_type dof_number(const unsigned int s,
393  const unsigned int vg,
394  const unsigned int vig,
395  const unsigned int comp,
396  const unsigned int n_comp) const;
397 
403  std::pair<unsigned int, unsigned int>
404  var_to_vg_and_offset(const unsigned int s,
405  const unsigned int var) const;
406 
411  void set_dof_number(const unsigned int s,
412  const unsigned int var,
413  const unsigned int comp,
414  const dof_id_type dn);
415 
420  bool has_dofs(const unsigned int s=libMesh::invalid_uint) const;
421 
427  void set_vg_dof_base(const unsigned int s,
428  const unsigned int vg,
429  const dof_id_type db);
430 
436  dof_id_type vg_dof_base(const unsigned int s,
437  const unsigned int vg) const;
438 
449  void add_extra_integers (const unsigned int n_integers);
450 
462  void add_extra_integers (const unsigned int n_integers,
463  const std::vector<dof_id_type> & default_values);
464 
472  unsigned int n_extra_integers () const;
473 
477  bool has_extra_integers () const;
478 
482  static const dof_id_type invalid_id = static_cast<dof_id_type>(-1);
483 
487  static const unique_id_type invalid_unique_id = static_cast<unique_id_type>(-1);
488 
494 
499  unsigned int packed_indexing_size() const;
500 
505  static unsigned int unpackable_indexing_size
506  (std::vector<largest_id_type>::const_iterator begin);
507 
513  void unpack_indexing(std::vector<largest_id_type>::const_iterator begin);
514 
520  void pack_indexing(std::back_insert_iterator<std::vector<largest_id_type>> target) const;
521 
525  void debug_buffer () const;
526 
530  void print_dof_info() const;
531 
532  // Deep copy (or almost-copy) of DofObjects is solely for a couple
533  // tricky internal uses.
534 private:
535 
540  DofObject (const DofObject &);
541 
550  std::unique_ptr<DofObject>
551  construct(const DofObject * other = nullptr);
552 
556  DofObject & operator= (const DofObject & dof_obj);
557 
562  unsigned int var_to_vg (const unsigned int s,
563  const unsigned int var) const;
564 
569  unsigned int system_var_to_vg_var (const unsigned int s,
570  const unsigned int vg,
571  const unsigned int var) const;
572 
576 #ifdef LIBMESH_ENABLE_UNIQUE_ID
578 #endif
579 
584 
595 
679  typedef std::vector<index_t> index_buffer_t;
681 
691  static const index_t ncv_magic = 256; // = 2^8, in case we want to manually bitshift
692  static const index_t ncv_magic_exp = 8; // Let's manually bitshift
693 
697  unsigned int start_idx(const unsigned int s) const;
698 
702  unsigned int end_idx(const unsigned int s) const;
703 
707  unsigned int start_idx_ints() const;
708 
712  unsigned int end_idx_ints() const;
713 
714  // methods only available for unit testing
715 #ifdef LIBMESH_IS_UNIT_TESTING
716 public:
717  void set_buffer (const std::vector<dof_id_type> & buf)
718  { _idx_buf = buf; }
719 #endif
720 };
721 
722 
723 
724 //------------------------------------------------------
725 // Inline functions
726 inline
728 #ifdef LIBMESH_ENABLE_UNIQUE_ID
729  _unique_id (invalid_unique_id),
730 #endif
731  _id (invalid_id),
732  _processor_id (invalid_processor_id)
733 {
734  this->invalidate();
735 }
736 
737 
738 
739 inline
740 std::unique_ptr<DofObject>
742 {
743  return other
744  ? std::unique_ptr<DofObject>(new DofObject(*other))
745  : std::unique_ptr<DofObject>(new DofObject());
746 }
747 
748 
749 
750 inline
751 void DofObject::invalidate_dofs (const unsigned int sys_num)
752 {
753  const unsigned int n_sys = this->n_systems();
754  // If the user does not specify the system number...
755  if (sys_num >= n_sys)
756  {
757  for (auto s : make_range(n_sys))
758  for (auto vg : make_range(this->n_var_groups(s)))
759  if (this->n_comp_group(s,vg))
760  this->set_vg_dof_base(s,vg,invalid_id);
761  }
762  // ...otherwise invalidate the dofs for all systems
763  else
764  for (auto vg : make_range(this->n_var_groups(sys_num)))
765  if (this->n_comp_group(sys_num,vg))
766  this->set_vg_dof_base(sys_num,vg,invalid_id);
767 }
768 
769 
770 
771 inline
773 {
774  this->set_id (invalid_id);
775 }
776 
777 
778 
779 inline
781 {
783 }
784 
785 
786 
787 inline
789 {
790  this->invalidate_dofs ();
791  this->invalidate_id ();
792  this->invalidate_processor_id ();
793 }
794 
795 
796 
797 inline
799 {
800  this->set_n_systems(0);
801 }
802 
803 
804 
805 inline
806 unsigned int DofObject::n_dofs (const unsigned int s,
807  const unsigned int var) const
808 {
809  libmesh_assert_less (s, this->n_systems());
810 
811  unsigned int num = 0;
812 
813  // Count all variables
814  if (var == libMesh::invalid_uint)
815  for (auto v : make_range(this->n_vars(s)))
816  num += this->n_comp(s,v);
817 
818  // Only count specified variable
819  else
820  num = this->n_comp(s,var);
821 
822  return num;
823 }
824 
825 
826 
827 inline
829 {
830  return _id;
831 }
832 
833 
834 
835 inline
837 {
838  return _id;
839 }
840 
841 
842 
843 inline
845 {
846 #ifdef LIBMESH_ENABLE_UNIQUE_ID
848  return _unique_id;
849 #else
850  return invalid_unique_id;
851 #endif
852 }
853 
854 
855 
856 #ifdef LIBMESH_ENABLE_DEPRECATED
857 inline
859 {
860 #ifdef LIBMESH_ENABLE_UNIQUE_ID
861  libmesh_deprecated();
862  return _unique_id;
863 #else
864  libmesh_not_implemented();
865 #endif
866 }
867 #endif // LIBMESH_ENABLE_DEPRECATED
868 
869 
870 
871 inline
873 {
874 #ifdef LIBMESH_ENABLE_UNIQUE_ID
875  _unique_id = new_id;
876 #else
877  libmesh_ignore(new_id);
878  libmesh_not_implemented();
879 #endif
880 }
881 
882 
883 
884 inline
885 bool DofObject::valid_id () const
886 {
887  return (DofObject::invalid_id != _id);
888 }
889 
890 
891 
892 inline
894 {
895 #ifdef LIBMESH_ENABLE_UNIQUE_ID
897 #else
898  return false;
899 #endif
900 }
901 
902 
903 
904 inline
906 {
907  return _processor_id;
908 }
909 
910 
911 
912 inline
914 {
915  return _processor_id;
916 }
917 
918 
919 
920 inline
922 {
923  this->processor_id() = pid;
924 }
925 
926 
927 
928 inline
930 {
932 }
933 
934 
935 
936 inline
937 unsigned int DofObject::n_systems () const
938 {
939  const int hdr = _idx_buf.empty() ?
940  0 : cast_int<int>(dof_id_signed_type(_idx_buf[0]));
941  return hdr >= 0 ? hdr : (-hdr-1);
942 }
943 
944 
945 
946 inline
947 unsigned int DofObject::n_pseudo_systems () const
948 {
949  const int hdr = _idx_buf.empty() ?
950  0 : cast_int<int>(dof_id_signed_type(_idx_buf[0]));
951  return std::abs(hdr);
952 }
953 
954 
955 
956 inline
957 unsigned int DofObject::n_var_groups(const unsigned int s) const
958 {
959  libmesh_assert_less (s, this->n_systems());
960 
961  return (this->end_idx(s) - this->start_idx(s)) / 2;
962 }
963 
964 
965 
966 inline
967 unsigned int DofObject::n_vars(const unsigned int s,
968  const unsigned int vg) const
969 {
970  libmesh_assert_less (s, this->n_systems());
971  libmesh_assert_less (vg, this->n_var_groups(s));
972 
973  const unsigned int start_idx_sys = this->start_idx(s);
974 
975  libmesh_assert_less ((start_idx_sys + 2*vg), _idx_buf.size());
976 
977  return (cast_int<unsigned int>
978  (_idx_buf[start_idx_sys + 2*vg]) >> ncv_magic_exp);
979 }
980 
981 
982 
983 inline
984 unsigned int DofObject::n_vars(const unsigned int s) const
985 {
986  libmesh_assert_less (s, this->n_systems());
987 
988  const unsigned int nvg = this->n_var_groups(s);
989 
990  unsigned int val=0;
991 
992  for (unsigned int vg=0; vg<nvg; vg++)
993  val += this->n_vars(s,vg);
994 
995  return val;
996 }
997 
998 
999 
1000 
1001 inline
1002 unsigned int DofObject::n_comp(const unsigned int s,
1003  const unsigned int var) const
1004 {
1005  libmesh_assert_less (s, this->n_systems());
1006  libmesh_assert_less (var, this->n_vars(s));
1007 
1008  return this->n_comp_group(s,this->var_to_vg(s,var));
1009 }
1010 
1011 
1012 
1013 
1014 inline
1015 unsigned int DofObject::n_comp_group(const unsigned int s,
1016  const unsigned int vg) const
1017 {
1018  libmesh_assert_less (s, this->n_systems());
1019  libmesh_assert_less (vg, this->n_var_groups(s));
1020 
1021  const unsigned int
1022  start_idx_sys = this->start_idx(s);
1023 
1024  libmesh_assert_less ((start_idx_sys + 2*vg), _idx_buf.size());
1025 
1026  return (_idx_buf[start_idx_sys + 2*vg] % ncv_magic);
1027 }
1028 
1029 
1030 
1031 inline
1032 dof_id_type DofObject::dof_number(const unsigned int s,
1033  const unsigned int var,
1034  const unsigned int comp) const
1035 {
1036  libmesh_assert_less (s, this->n_systems());
1037  libmesh_assert_less (var, this->n_vars(s));
1038  libmesh_assert_less (comp, this->n_comp(s,var));
1039 
1040  const std::pair<unsigned int, unsigned int>
1041  vg_vig = this->var_to_vg_and_offset(s,var);
1042 
1043  const unsigned int
1044  n_comp = this->n_comp_group(s,vg_vig.first);
1045 
1046  return this->dof_number(s, vg_vig.first, vg_vig.second,
1047  comp, n_comp);
1048 }
1049 
1050 
1051 
1052 inline
1053 dof_id_type DofObject::dof_number(const unsigned int s,
1054  const unsigned int vg,
1055  const unsigned int vig,
1056  const unsigned int comp,
1057  const unsigned int n_comp) const
1058 {
1059  libmesh_assert_less (s, this->n_systems());
1060  libmesh_assert_less (vg, this->n_var_groups(s));
1061  libmesh_assert_less (vig, this->n_vars(s,vg));
1062 
1063  const unsigned int
1064  start_idx_sys = this->start_idx(s);
1065 
1066  libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
1067 
1068  const dof_id_type
1069  base_idx = _idx_buf[start_idx_sys + 2*vg + 1];
1070 
1071  // if the first component is invalid, they
1072  // are all invalid
1073  if (base_idx == invalid_id)
1074  return invalid_id;
1075 
1076  // otherwise the index is the first component
1077  // index augmented by the component number
1078  else
1079  return cast_int<dof_id_type>(base_idx + vig*n_comp + comp);
1080 }
1081 
1082 
1083 
1084 inline
1085 void
1086 DofObject::set_extra_integer(const unsigned int index,
1087  const dof_id_type value)
1088 {
1089  libmesh_assert_less(index, this->n_extra_integers());
1090  libmesh_assert_less(this->n_pseudo_systems(), _idx_buf.size());
1091 
1092  const unsigned int start_idx_i = this->start_idx_ints();
1093 
1094  libmesh_assert_less(start_idx_i+index, _idx_buf.size());
1095  _idx_buf[start_idx_i+index] = value;
1096 }
1097 
1098 
1099 
1100 inline
1102 DofObject::get_extra_integer (const unsigned int index) const
1103 {
1104  libmesh_assert_less(index, this->n_extra_integers());
1105  libmesh_assert_less(this->n_systems(), _idx_buf.size());
1106 
1107  const unsigned int start_idx_i = this->start_idx_ints();
1108 
1109  libmesh_assert_less(start_idx_i+index, _idx_buf.size());
1110  return _idx_buf[start_idx_i+index];
1111 }
1112 
1113 
1114 
1115 // If we're using a type T that's a class with no trivial
1116 // copy-assignment, -Wclass-memaccess will scream about doing it with
1117 // memcpy, even if (as with boost::multiprecision::float128) this is a
1118 // false positive.
1119 #include "libmesh/ignore_warnings.h"
1120 
1121 
1122 
1123 template <typename T>
1124 inline
1125 void
1126 DofObject::set_extra_datum(const unsigned int index,
1127  const T value)
1128 {
1129 #ifndef NDEBUG
1130  const unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
1131 #endif
1132  libmesh_assert_less(index+n_more_integers, this->n_extra_integers());
1133  libmesh_assert_less(this->n_pseudo_systems(), _idx_buf.size());
1134 
1135  const unsigned int start_idx_i = this->start_idx_ints();
1136 
1137  libmesh_assert_less(start_idx_i+index+n_more_integers, _idx_buf.size());
1138  std::memcpy(&_idx_buf[start_idx_i+index], &value, sizeof(T));
1139 }
1140 
1141 
1142 
1143 template <typename T>
1144 inline
1145 T
1146 DofObject::get_extra_datum (const unsigned int index) const
1147 {
1148 #ifndef NDEBUG
1149  const unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
1150 #endif
1151  libmesh_assert_less(index+n_more_integers, this->n_extra_integers());
1152  libmesh_assert_less(this->n_systems(), _idx_buf.size());
1153 
1154  const unsigned int start_idx_i = this->start_idx_ints();
1155 
1156  libmesh_assert_less(start_idx_i+index+n_more_integers, _idx_buf.size());
1157  T returnval;
1158  std::memcpy(&returnval, &_idx_buf[start_idx_i+index], sizeof(T));
1159  return returnval;
1160 }
1161 
1162 
1163 
1164 #include "libmesh/restore_warnings.h"
1165 
1166 
1167 
1168 inline
1169 unsigned int
1171 {
1172  if (_idx_buf.empty())
1173  return 0;
1174 
1175  const int hdr = dof_id_signed_type(_idx_buf[0]);
1176  if (hdr >= 0)
1177  return 0;
1178 
1179  const unsigned int start_idx_i = this->start_idx_ints();
1180 
1181  return _idx_buf.size() - start_idx_i;
1182 }
1183 
1184 
1185 
1186 inline
1187 bool
1189 {
1190  if (_idx_buf.empty())
1191  return 0;
1192 
1193  return (dof_id_signed_type(_idx_buf[0]) < 0);
1194 }
1195 
1196 
1197 
1198 inline
1199 std::pair<unsigned int, unsigned int>
1200 DofObject::var_to_vg_and_offset(const unsigned int s,
1201  const unsigned int var) const
1202 {
1203  std::pair<unsigned int, unsigned int> returnval(0,0);
1204 
1205  unsigned int & vg = returnval.first;
1206  unsigned int & offset = returnval.second;
1207 
1208  unsigned int vg_start = 0;
1209  for (; ; vg++)
1210  {
1211  libmesh_assert_less(vg, this->n_var_groups(s));
1212 
1213  const unsigned int vg_end = vg_start + this->n_vars(s,vg);
1214  if (var < vg_end)
1215  {
1216  offset = var - vg_start;
1217  return returnval;
1218  }
1219  vg_start = vg_end;
1220  }
1221 }
1222 
1223 
1224 
1225 inline
1226 bool DofObject::has_dofs (const unsigned int sys) const
1227 {
1228  if (sys == libMesh::invalid_uint)
1229  {
1230  for (auto s : make_range(this->n_systems()))
1231  if (this->n_vars(s))
1232  return true;
1233  }
1234 
1235  else
1236  {
1237  libmesh_assert_less (sys, this->n_systems());
1238 
1239  if (this->n_vars(sys))
1240  return true;
1241  }
1242 
1243  return false;
1244 }
1245 
1246 
1247 
1248 inline
1249 unsigned int DofObject::start_idx (const unsigned int s) const
1250 {
1251  libmesh_assert_less (s, this->n_systems());
1252  libmesh_assert_less (s, _idx_buf.size());
1253 
1254  return cast_int<unsigned int>(std::abs(dof_id_signed_type(_idx_buf[s])));
1255 }
1256 
1257 
1258 
1259 inline
1260 unsigned int DofObject::end_idx (const unsigned int s) const
1261 {
1262  libmesh_assert_less (s, this->n_systems());
1263  libmesh_assert_less (s, _idx_buf.size());
1264 
1265  return ((s+1) == this->n_pseudo_systems()) ?
1266  cast_int<unsigned int>(_idx_buf.size()) :
1267  cast_int<unsigned int>(_idx_buf[s+1]);
1268 }
1269 
1270 
1271 
1272 inline
1273 unsigned int DofObject::start_idx_ints () const
1274 {
1276 
1277  unsigned int n_sys = this->n_systems();
1278 
1279  libmesh_assert_less(this->n_systems(), _idx_buf.size());
1280  return n_sys ? cast_int<unsigned int>(_idx_buf[this->n_systems()]) :
1281  (n_sys+1);
1282 }
1283 
1284 
1285 
1286 inline
1287 unsigned int DofObject::end_idx_ints () const
1288 {
1290 
1291  return cast_int<unsigned int>(_idx_buf.size());
1292 }
1293 
1294 
1295 
1296 inline
1297 void DofObject::set_vg_dof_base(const unsigned int s,
1298  const unsigned int vg,
1299  const dof_id_type db)
1300 {
1301  libmesh_assert_less (s, this->n_systems());
1302  libmesh_assert_less (vg, this->n_var_groups(s));
1303 
1304  const unsigned int
1305  start_idx_sys = this->start_idx(s);
1306 
1307  libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
1308 
1309  _idx_buf[start_idx_sys + 2*vg + 1] = db;
1310 
1311  libmesh_assert_equal_to (this->vg_dof_base(s,vg), db);
1312 }
1313 
1314 
1315 
1316 inline
1318  const unsigned int vg) const
1319 {
1320  libmesh_assert_less (s, this->n_systems());
1321  libmesh_assert_less (vg, this->n_var_groups(s));
1322 
1323  const unsigned int
1324  start_idx_sys = this->start_idx(s);
1325 
1326  libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
1327 
1328  // #ifdef DEBUG
1329  // std::cout << " [ ";
1330  // for (auto i : _idx_buf)
1331  // std::cout << i << " ";
1332  // std::cout << "]\n";
1333  // #endif
1334 
1335  return _idx_buf[start_idx_sys + 2*vg + 1];
1336 }
1337 
1338 
1339 
1340 inline
1341 unsigned int DofObject::var_to_vg (const unsigned int s,
1342  const unsigned int var) const
1343 {
1344  const unsigned int
1345  nvg = this->n_var_groups(s);
1346 
1347  for (unsigned int vg=0, vg_end=0; vg<nvg; vg++)
1348  {
1349  vg_end += this->n_vars(s,vg);
1350  if (var < vg_end) return vg;
1351  }
1352 
1353  libmesh_error_msg("Error: could not map variable " << var << " to variable group.");
1354 }
1355 
1356 
1357 
1358 inline
1359 unsigned int DofObject::system_var_to_vg_var (const unsigned int s,
1360  const unsigned int vg,
1361  const unsigned int var) const
1362 {
1363  unsigned int accumulated_sum=0;
1364 
1365  for (unsigned int vgc=0; vgc<vg; vgc++)
1366  accumulated_sum += this->n_vars(s,vgc);
1367 
1368  libmesh_assert_less_equal (accumulated_sum, var);
1369 
1370  return (var - accumulated_sum);
1371 }
1372 
1379 {
1380  bool operator()(const DofObject * a,
1381  const DofObject * b) const
1382  {
1383  libmesh_assert (a);
1384  libmesh_assert (b);
1385 
1386  return a->id() < b->id();
1387  }
1388 };
1389 
1391 {
1392  bool operator()(const DofObject * a,
1393  const DofObject * b) const
1394  {
1395  libmesh_assert (a);
1396  libmesh_assert (b);
1397 
1398  if (a->processor_id() < b->processor_id())
1399  return true;
1400  if (b->processor_id() < a->processor_id())
1401  return false;
1402 
1403  return a->id() < b->id();
1404  }
1405 };
1406 
1407 } // namespace libMesh
1408 
1409 
1410 #endif // #ifndef LIBMESH_DOF_OBJECT_H
void set_n_comp(const unsigned int s, const unsigned int var, const unsigned int ncomp)
Sets the number of components for Variable var of system s associated with this DofObject.
Definition: dof_object.C:385
unsigned int system_var_to_vg_var(const unsigned int s, const unsigned int vg, const unsigned int var) const
Utility function - for variable var in system s, figure out what variable group it lives in...
Definition: dof_object.h:1359
dof_id_type vg_dof_base(const unsigned int s, const unsigned int vg) const
VariableGroup DoF indices are indexed as id = base + var_in_vg*ncomp + comp This method allows for di...
Definition: dof_object.h:1317
unique_id_type & set_unique_id()
Definition: dof_object.h:858
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
Definition: dof_object.h:1032
std::unique_ptr< DofObject > construct(const DofObject *other=nullptr)
Convenient factory function that calls either the (deep) copy constructor or the default constructor ...
Definition: dof_object.h:741
void set_old_dof_object()
Sets the old_dof_object to a copy of this.
Definition: dof_object.C:135
void clear_dofs()
Clear the DofMap data structures holding degree of freedom data.
Definition: dof_object.h:798
static unsigned int unpackable_indexing_size(std::vector< largest_id_type >::const_iterator begin)
If we have indices packed into an buffer for communications, how much of that buffer applies to this ...
Definition: dof_object.C:575
Comparison object to use with DofObject pointers.
Definition: dof_object.h:1378
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
unsigned int n_comp(const unsigned int s, const unsigned int var) const
Definition: dof_object.h:1002
unsigned int n_var_groups(const unsigned int s) const
Definition: dof_object.h:957
unsigned int var_to_vg(const unsigned int s, const unsigned int var) const
Utility function - for variable var in system s, figure out what variable group it lives in...
Definition: dof_object.h:1341
bool operator()(const DofObject *a, const DofObject *b) const
Definition: dof_object.h:1392
void set_id(const dof_id_type dofid)
Sets the id for this DofObject.
Definition: dof_object.h:201
unsigned int n_pseudo_systems() const
Definition: dof_object.h:947
unique_id_type unique_id() const
Definition: dof_object.h:844
dof_id_type _id
The id of the DofObject.
Definition: dof_object.h:583
void invalidate()
Invalidates all the indices for this DofObject.
Definition: dof_object.h:788
void set_vg_dof_base(const unsigned int s, const unsigned int vg, const dof_id_type db)
VariableGroup DoF indices are indexed as id = base + var_in_vg*ncomp + comp This method allows for di...
Definition: dof_object.h:1297
The libMesh namespace provides an interface to certain functionality in the library.
bool has_dofs(const unsigned int s=libMesh::invalid_uint) const
Definition: dof_object.h:1226
uint8_t processor_id_type
Definition: id_types.h:104
dof_id_type & set_id()
Definition: dof_object.h:836
DofObject()
Constructor.
Definition: dof_object.h:727
unsigned int start_idx_ints() const
The starting index for an extra_integers pseudosystem.
Definition: dof_object.h:1273
dof_id_type index_t
DoF index information.
Definition: dof_object.h:678
unique_id_type _unique_id
A globally unique id, guaranteed not to change as the mesh is repartitioned or adapted.
Definition: dof_object.h:577
unsigned int n_dofs(const unsigned int s, const unsigned int var=libMesh::invalid_uint) const
Definition: dof_object.h:806
void add_system()
Adds an additional system to the DofObject.
Definition: dof_object.C:195
unsigned int end_idx(const unsigned int s) const
The ending index for system s.
Definition: dof_object.h:1260
void libmesh_ignore(const Args &...)
void set_buffer(const std::vector< dof_id_type > &buf)
Definition: dof_object.h:717
dof_id_type id() const
Definition: dof_object.h:828
DofObject & operator=(const DofObject &dof_obj)
Deep-copying assignment operator.
Definition: dof_object.C:77
static const unique_id_type invalid_unique_id
An invalid unique_id to distinguish an uninitialized DofObject.
Definition: dof_object.h:487
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
void set_dof_number(const unsigned int s, const unsigned int var, const unsigned int comp, const dof_id_type dn)
Sets the global degree of freedom number for variable var, component comp for system s associated wit...
Definition: dof_object.C:454
unsigned int end_idx_ints() const
The ending index for an extra_integers pseudosystem.
Definition: dof_object.h:1287
unsigned int n_vars(const unsigned int s, const unsigned int vg) const
Definition: dof_object.h:967
unsigned int n_systems() const
Definition: dof_object.h:937
processor_id_type _processor_id
The local processor id.
Definition: libmesh.C:254
void print_dof_info() const
Print out info for debugging.
Definition: dof_object.C:670
bool valid_processor_id() const
Definition: dof_object.h:929
void clear_old_dof_object()
Sets the old_dof_object to nullptr.
Definition: dof_object.C:128
void invalidate_id()
Sets the id to invalid_id.
Definition: dof_object.h:772
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:482
int8_t dof_id_signed_type
Definition: id_types.h:68
void set_extra_datum(const unsigned int index, const T value)
Sets the value on this object of the extra datum associated with index, which should have been obtain...
Definition: dof_object.h:1126
bool valid_unique_id() const
Definition: dof_object.h:893
DofObject * get_old_dof_object()
Pointer accessor for previously public old_dof_object.
Definition: dof_object.h:96
bool has_extra_integers() const
Returns whether extra integers are associated to the DofObject.
Definition: dof_object.h:1188
const DofObject & get_old_dof_object_ref() const
Definition: dof_object.h:110
This class implements reference counting.
void invalidate_processor_id()
Sets the processor id to invalid_processor_id.
Definition: dof_object.h:780
std::vector< index_t > index_buffer_t
Definition: dof_object.h:679
void set_n_comp_group(const unsigned int s, const unsigned int vg, const unsigned int ncomp)
Sets the number of components for VariableGroup vg of system s associated with this DofObject...
Definition: dof_object.C:397
DofObject & get_old_dof_object_ref()
As above, but do not use in situations where the old_dof_object may be nullptr, since this function a...
Definition: dof_object.h:104
void set_n_systems(const unsigned int s)
Sets the number of systems for this DofObject.
Definition: dof_object.C:150
~DofObject()=default
Destructor.
bool operator()(const DofObject *a, const DofObject *b) const
Definition: dof_object.h:1380
const DofObject * get_old_dof_object() const
Definition: dof_object.h:97
void set_n_vars_per_group(const unsigned int s, const std::vector< unsigned int > &nvpg)
Sets number of variables in each group associated with system s for this DofObject.
Definition: dof_object.C:247
bool valid_id() const
Definition: dof_object.h:885
unsigned int start_idx(const unsigned int s) const
The starting index for system s.
Definition: dof_object.h:1249
unsigned int packed_indexing_size() const
If we pack our indices into an buffer for communications, how many ints do we need?
Definition: dof_object.C:560
std::unique_ptr< DofObject > old_dof_object
This object on the last mesh.
Definition: dof_object.h:88
void pack_indexing(std::back_insert_iterator< std::vector< largest_id_type >> target) const
A method for creating packed data from our index buffer - basically a copy with prepended size with o...
Definition: dof_object.C:642
void invalidate_dofs(const unsigned int sys_num=libMesh::invalid_uint)
Sets all degree of freedom numbers to invalid_id.
Definition: dof_object.h:751
static const bool value
Definition: xdr_io.C:54
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:140
void unpack_indexing(std::vector< largest_id_type >::const_iterator begin)
A method for creating our index buffer from packed data - basically with our current implementation w...
Definition: dof_object.C:595
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition: dof_object.h:54
void add_extra_integers(const unsigned int n_integers)
Assigns a set of extra integers to this DofObject.
Definition: dof_object.C:490
std::pair< unsigned int, unsigned int > var_to_vg_and_offset(const unsigned int s, const unsigned int var) const
Definition: dof_object.h:1200
unsigned int n_extra_integers() const
Returns how many extra integers are associated to the DofObject.
Definition: dof_object.h:1170
T get_extra_datum(const unsigned int index) const
Gets the value on this object of the extra datum associated with index, which should have been obtain...
Definition: dof_object.h:1146
index_buffer_t _idx_buf
Definition: dof_object.h:680
void debug_buffer() const
Print our buffer for debugging.
Definition: dof_object.C:660
unsigned int n_comp_group(const unsigned int s, const unsigned int vg) const
Definition: dof_object.h:1015
processor_id_type processor_id() const
Definition: dof_object.h:905
uint8_t unique_id_type
Definition: id_types.h:86
processor_id_type _processor_id
The processor_id of the DofObject.
Definition: dof_object.h:594
static const index_t ncv_magic_exp
Definition: dof_object.h:692
void set_extra_integer(const unsigned int index, const dof_id_type value)
Sets the value on this object of the extra integer associated with index, which should have been obta...
Definition: dof_object.h:1086
dof_id_type get_extra_integer(const unsigned int index) const
Gets the value on this object of the extra integer associated with index, which should have been obta...
Definition: dof_object.h:1102
uint8_t dof_id_type
Definition: id_types.h:67
static const index_t ncv_magic
Above we introduced the chimera ncv, which is a hybrid of the form ncv = ncv_magic*nv + nc where nv a...
Definition: dof_object.h:691