libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
dof_object.h
浏览该文件的文档.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2023 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  {
106  libmesh_assert(old_dof_object);
107  return *old_dof_object;
108  }
109 
111  {
112  libmesh_assert(old_dof_object);
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 
162  unsigned int n_dofs (const unsigned int s,
163  const unsigned int var =
164  libMesh::invalid_uint) const;
165 
169  dof_id_type id () const;
170 
174  dof_id_type & set_id ();
175 
179  unique_id_type unique_id () const;
180 
187 
191  void set_unique_id (unique_id_type new_id);
192 
196  void set_id (const dof_id_type dofid)
197  { this->set_id() = dofid; }
198 
203  bool valid_id () const;
204 
209  bool valid_unique_id () const;
210 
219 
225 
229  void processor_id (const processor_id_type pid);
230 
235  bool valid_processor_id () const;
236 
241  unsigned int n_systems() const;
242 
248  unsigned int n_pseudo_systems() const;
249 
258  void set_n_systems (const unsigned int s);
259 
265  void set_extra_integer (const unsigned int index, const dof_id_type value);
266 
272  dof_id_type get_extra_integer (const unsigned int index) const;
273 
280  template <typename T>
281  void set_extra_datum (const unsigned int index, const T value);
282 
289  template <typename T>
290  T get_extra_datum (const unsigned int index) const;
291 
292 
296  void add_system ();
297 
302  unsigned int n_var_groups(const unsigned int s) const;
303 
308  unsigned int n_vars(const unsigned int s,
309  const unsigned int vg) const;
310 
315  unsigned int n_vars(const unsigned int s) const;
316 
324  void set_n_vars_per_group(const unsigned int s,
325  const std::vector<unsigned int> & nvpg);
326 
336  unsigned int n_comp(const unsigned int s,
337  const unsigned int var) const;
338 
348  unsigned int n_comp_group(const unsigned int s,
349  const unsigned int vg) const;
350 
355  void set_n_comp(const unsigned int s,
356  const unsigned int var,
357  const unsigned int ncomp);
358 
363  void set_n_comp_group(const unsigned int s,
364  const unsigned int vg,
365  const unsigned int ncomp);
366 
375  dof_id_type dof_number(const unsigned int s,
376  const unsigned int var,
377  const unsigned int comp) const;
378 
387  dof_id_type dof_number(const unsigned int s,
388  const unsigned int vg,
389  const unsigned int vig,
390  const unsigned int comp,
391  const unsigned int n_comp) const;
392 
398  std::pair<unsigned int, unsigned int>
399  var_to_vg_and_offset(const unsigned int s,
400  const unsigned int var) const;
401 
406  void set_dof_number(const unsigned int s,
407  const unsigned int var,
408  const unsigned int comp,
409  const dof_id_type dn);
410 
415  bool has_dofs(const unsigned int s=libMesh::invalid_uint) const;
416 
422  void set_vg_dof_base(const unsigned int s,
423  const unsigned int vg,
424  const dof_id_type db);
425 
431  dof_id_type vg_dof_base(const unsigned int s,
432  const unsigned int vg) const;
433 
444  void add_extra_integers (const unsigned int n_integers);
445 
457  void add_extra_integers (const unsigned int n_integers,
458  const std::vector<dof_id_type> & default_values);
459 
467  unsigned int n_extra_integers () const;
468 
472  bool has_extra_integers () const;
473 
477  static const dof_id_type invalid_id = static_cast<dof_id_type>(-1);
478 
482  static const unique_id_type invalid_unique_id = static_cast<unique_id_type>(-1);
483 
489 
494  unsigned int packed_indexing_size() const;
495 
500  static unsigned int unpackable_indexing_size
501  (std::vector<largest_id_type>::const_iterator begin);
502 
508  void unpack_indexing(std::vector<largest_id_type>::const_iterator begin);
509 
515  void pack_indexing(std::back_insert_iterator<std::vector<largest_id_type>> target) const;
516 
520  void debug_buffer () const;
521 
525  void print_dof_info() const;
526 
527  // Deep copy (or almost-copy) of DofObjects is solely for a couple
528  // tricky internal uses.
529 private:
530 
535  DofObject (const DofObject &);
536 
545  std::unique_ptr<DofObject>
546  construct(const DofObject * other = nullptr);
547 
551  DofObject & operator= (const DofObject & dof_obj);
552 
557  unsigned int var_to_vg (const unsigned int s,
558  const unsigned int var) const;
559 
564  unsigned int system_var_to_vg_var (const unsigned int s,
565  const unsigned int vg,
566  const unsigned int var) const;
567 
571 #ifdef LIBMESH_ENABLE_UNIQUE_ID
573 #endif
574 
579 
590 
674  typedef std::vector<index_t> index_buffer_t;
676 
686  static const index_t ncv_magic = 256; // = 2^8, in case we want to manually bitshift
687  static const index_t ncv_magic_exp = 8; // Let's manually bitshift
688 
692  unsigned int start_idx(const unsigned int s) const;
693 
697  unsigned int end_idx(const unsigned int s) const;
698 
702  unsigned int start_idx_ints() const;
703 
707  unsigned int end_idx_ints() const;
708 
709  // methods only available for unit testing
710 #ifdef LIBMESH_IS_UNIT_TESTING
711 public:
712  void set_buffer (const std::vector<dof_id_type> & buf)
713  { _idx_buf = buf; }
714 #endif
715 };
716 
717 
718 
719 //------------------------------------------------------
720 // Inline functions
721 inline
723 #ifdef LIBMESH_ENABLE_UNIQUE_ID
724  _unique_id (invalid_unique_id),
725 #endif
726  _id (invalid_id),
727  _processor_id (invalid_processor_id)
728 {
729  this->invalidate();
730 }
731 
732 
733 
734 inline
735 std::unique_ptr<DofObject>
737 {
738  return other
739  ? std::unique_ptr<DofObject>(new DofObject(*other))
740  : std::unique_ptr<DofObject>(new DofObject());
741 }
742 
743 
744 
745 inline
746 void DofObject::invalidate_dofs (const unsigned int sys_num)
747 {
748  const unsigned int n_sys = this->n_systems();
749  // If the user does not specify the system number...
750  if (sys_num >= n_sys)
751  {
752  for (auto s : make_range(n_sys))
753  for (auto vg : make_range(this->n_var_groups(s)))
754  if (this->n_comp_group(s,vg))
755  this->set_vg_dof_base(s,vg,invalid_id);
756  }
757  // ...otherwise invalidate the dofs for all systems
758  else
759  for (auto vg : make_range(this->n_var_groups(sys_num)))
760  if (this->n_comp_group(sys_num,vg))
761  this->set_vg_dof_base(sys_num,vg,invalid_id);
762 }
763 
764 
765 
766 inline
768 {
769  this->set_id (invalid_id);
770 }
771 
772 
773 
774 inline
776 {
778 }
779 
780 
781 
782 inline
784 {
785  this->invalidate_dofs ();
786  this->invalidate_id ();
787  this->invalidate_processor_id ();
788 }
789 
790 
791 
792 inline
794 {
795  this->set_n_systems(0);
796 }
797 
798 
799 
800 inline
801 unsigned int DofObject::n_dofs (const unsigned int s,
802  const unsigned int var) const
803 {
804  libmesh_assert_less (s, this->n_systems());
805 
806  unsigned int num = 0;
807 
808  // Count all variables
809  if (var == libMesh::invalid_uint)
810  for (auto v : make_range(this->n_vars(s)))
811  num += this->n_comp(s,v);
812 
813  // Only count specified variable
814  else
815  num = this->n_comp(s,var);
816 
817  return num;
818 }
819 
820 
821 
822 inline
824 {
825  return _id;
826 }
827 
828 
829 
830 inline
832 {
833  return _id;
834 }
835 
836 
837 
838 inline
840 {
841 #ifdef LIBMESH_ENABLE_UNIQUE_ID
842  libmesh_assert (this->valid_unique_id());
843  return _unique_id;
844 #else
845  return invalid_unique_id;
846 #endif
847 }
848 
849 
850 
851 inline
853 {
854 #ifdef LIBMESH_ENABLE_UNIQUE_ID
855  libmesh_deprecated();
856  return _unique_id;
857 #else
858  libmesh_not_implemented();
859 #endif
860 }
861 
862 
863 
864 inline
866 {
867 #ifdef LIBMESH_ENABLE_UNIQUE_ID
868  _unique_id = new_id;
869 #else
870  libmesh_ignore(new_id);
871  libmesh_not_implemented();
872 #endif
873 }
874 
875 
876 
877 inline
878 bool DofObject::valid_id () const
879 {
880  return (DofObject::invalid_id != _id);
881 }
882 
883 
884 
885 inline
887 {
888 #ifdef LIBMESH_ENABLE_UNIQUE_ID
890 #else
891  return false;
892 #endif
893 }
894 
895 
896 
897 inline
899 {
900  return _processor_id;
901 }
902 
903 
904 
905 inline
907 {
908  return _processor_id;
909 }
910 
911 
912 
913 inline
915 {
916  this->processor_id() = pid;
917 }
918 
919 
920 
921 inline
923 {
925 }
926 
927 
928 
929 inline
930 unsigned int DofObject::n_systems () const
931 {
932  const int hdr = _idx_buf.empty() ?
933  0 : cast_int<int>(dof_id_signed_type(_idx_buf[0]));
934  return hdr >= 0 ? hdr : (-hdr-1);
935 }
936 
937 
938 
939 inline
940 unsigned int DofObject::n_pseudo_systems () const
941 {
942  const int hdr = _idx_buf.empty() ?
943  0 : cast_int<int>(dof_id_signed_type(_idx_buf[0]));
944  return std::abs(hdr);
945 }
946 
947 
948 
949 inline
950 unsigned int DofObject::n_var_groups(const unsigned int s) const
951 {
952  libmesh_assert_less (s, this->n_systems());
953 
954  return (this->end_idx(s) - this->start_idx(s)) / 2;
955 }
956 
957 
958 
959 inline
960 unsigned int DofObject::n_vars(const unsigned int s,
961  const unsigned int vg) const
962 {
963  libmesh_assert_less (s, this->n_systems());
964  libmesh_assert_less (vg, this->n_var_groups(s));
965 
966  const unsigned int start_idx_sys = this->start_idx(s);
967 
968  libmesh_assert_less ((start_idx_sys + 2*vg), _idx_buf.size());
969 
970  return (cast_int<unsigned int>
971  (_idx_buf[start_idx_sys + 2*vg]) >> ncv_magic_exp);
972 }
973 
974 
975 
976 inline
977 unsigned int DofObject::n_vars(const unsigned int s) const
978 {
979  libmesh_assert_less (s, this->n_systems());
980 
981  const unsigned int nvg = this->n_var_groups(s);
982 
983  unsigned int val=0;
984 
985  for (unsigned int vg=0; vg<nvg; vg++)
986  val += this->n_vars(s,vg);
987 
988  return val;
989 }
990 
991 
992 
993 
994 inline
995 unsigned int DofObject::n_comp(const unsigned int s,
996  const unsigned int var) const
997 {
998  libmesh_assert_less (s, this->n_systems());
999  libmesh_assert_less (var, this->n_vars(s));
1000 
1001  return this->n_comp_group(s,this->var_to_vg(s,var));
1002 }
1003 
1004 
1005 
1006 
1007 inline
1008 unsigned int DofObject::n_comp_group(const unsigned int s,
1009  const unsigned int vg) const
1010 {
1011  libmesh_assert_less (s, this->n_systems());
1012  libmesh_assert_less (vg, this->n_var_groups(s));
1013 
1014  const unsigned int
1015  start_idx_sys = this->start_idx(s);
1016 
1017  libmesh_assert_less ((start_idx_sys + 2*vg), _idx_buf.size());
1018 
1019  return (_idx_buf[start_idx_sys + 2*vg] % ncv_magic);
1020 }
1021 
1022 
1023 
1024 inline
1025 dof_id_type DofObject::dof_number(const unsigned int s,
1026  const unsigned int var,
1027  const unsigned int comp) const
1028 {
1029  libmesh_assert_less (s, this->n_systems());
1030  libmesh_assert_less (var, this->n_vars(s));
1031  libmesh_assert_less (comp, this->n_comp(s,var));
1032 
1033  const std::pair<unsigned int, unsigned int>
1034  vg_vig = this->var_to_vg_and_offset(s,var);
1035 
1036  const unsigned int
1037  n_comp = this->n_comp_group(s,vg_vig.first);
1038 
1039  return this->dof_number(s, vg_vig.first, vg_vig.second,
1040  comp, n_comp);
1041 }
1042 
1043 
1044 
1045 inline
1046 dof_id_type DofObject::dof_number(const unsigned int s,
1047  const unsigned int vg,
1048  const unsigned int vig,
1049  const unsigned int comp,
1050  const unsigned int n_comp) const
1051 {
1052  libmesh_assert_less (s, this->n_systems());
1053  libmesh_assert_less (vg, this->n_var_groups(s));
1054  libmesh_assert_less (vig, this->n_vars(s,vg));
1055 
1056  const unsigned int
1057  start_idx_sys = this->start_idx(s);
1058 
1059  libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
1060 
1061  const dof_id_type
1062  base_idx = _idx_buf[start_idx_sys + 2*vg + 1];
1063 
1064  // if the first component is invalid, they
1065  // are all invalid
1066  if (base_idx == invalid_id)
1067  return invalid_id;
1068 
1069  // otherwise the index is the first component
1070  // index augmented by the component number
1071  else
1072  return cast_int<dof_id_type>(base_idx + vig*n_comp + comp);
1073 }
1074 
1075 
1076 
1077 inline
1078 void
1079 DofObject::set_extra_integer(const unsigned int index,
1080  const dof_id_type value)
1081 {
1082  libmesh_assert_less(index, this->n_extra_integers());
1083  libmesh_assert_less(this->n_pseudo_systems(), _idx_buf.size());
1084 
1085  const unsigned int start_idx_i = this->start_idx_ints();
1086 
1087  libmesh_assert_less(start_idx_i+index, _idx_buf.size());
1088  _idx_buf[start_idx_i+index] = value;
1089 }
1090 
1091 
1092 
1093 inline
1095 DofObject::get_extra_integer (const unsigned int index) const
1096 {
1097  libmesh_assert_less(index, this->n_extra_integers());
1098  libmesh_assert_less(this->n_systems(), _idx_buf.size());
1099 
1100  const unsigned int start_idx_i = this->start_idx_ints();
1101 
1102  libmesh_assert_less(start_idx_i+index, _idx_buf.size());
1103  return _idx_buf[start_idx_i+index];
1104 }
1105 
1106 
1107 
1108 // If we're using a type T that's a class with no trivial
1109 // copy-assignment, -Wclass-memaccess will scream about doing it with
1110 // memcpy, even if (as with boost::multiprecision::float128) this is a
1111 // false positive.
1112 #include "libmesh/ignore_warnings.h"
1113 
1114 
1115 
1116 template <typename T>
1117 inline
1118 void
1119 DofObject::set_extra_datum(const unsigned int index,
1120  const T value)
1121 {
1122 #ifndef NDEBUG
1123  const unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
1124 #endif
1125  libmesh_assert_less(index+n_more_integers, this->n_extra_integers());
1126  libmesh_assert_less(this->n_pseudo_systems(), _idx_buf.size());
1127 
1128  const unsigned int start_idx_i = this->start_idx_ints();
1129 
1130  libmesh_assert_less(start_idx_i+index+n_more_integers, _idx_buf.size());
1131  std::memcpy(&_idx_buf[start_idx_i+index], &value, sizeof(T));
1132 }
1133 
1134 
1135 
1136 template <typename T>
1137 inline
1138 T
1139 DofObject::get_extra_datum (const unsigned int index) const
1140 {
1141 #ifndef NDEBUG
1142  const unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
1143 #endif
1144  libmesh_assert_less(index+n_more_integers, this->n_extra_integers());
1145  libmesh_assert_less(this->n_systems(), _idx_buf.size());
1146 
1147  const unsigned int start_idx_i = this->start_idx_ints();
1148 
1149  libmesh_assert_less(start_idx_i+index+n_more_integers, _idx_buf.size());
1150  T returnval;
1151  std::memcpy(&returnval, &_idx_buf[start_idx_i+index], sizeof(T));
1152  return returnval;
1153 }
1154 
1155 
1156 
1157 #include "libmesh/restore_warnings.h"
1158 
1159 
1160 
1161 inline
1162 unsigned int
1164 {
1165  if (_idx_buf.empty())
1166  return 0;
1167 
1168  const int hdr = dof_id_signed_type(_idx_buf[0]);
1169  if (hdr >= 0)
1170  return 0;
1171 
1172  const unsigned int start_idx_i = this->start_idx_ints();
1173 
1174  return _idx_buf.size() - start_idx_i;
1175 }
1176 
1177 
1178 
1179 inline
1180 bool
1182 {
1183  if (_idx_buf.empty())
1184  return 0;
1185 
1186  return (dof_id_signed_type(_idx_buf[0]) < 0);
1187 }
1188 
1189 
1190 
1191 inline
1192 std::pair<unsigned int, unsigned int>
1193 DofObject::var_to_vg_and_offset(const unsigned int s,
1194  const unsigned int var) const
1195 {
1196  std::pair<unsigned int, unsigned int> returnval(0,0);
1197 
1198  unsigned int & vg = returnval.first;
1199  unsigned int & offset = returnval.second;
1200 
1201  unsigned int vg_start = 0;
1202  for (; ; vg++)
1203  {
1204  libmesh_assert_less(vg, this->n_var_groups(s));
1205 
1206  const unsigned int vg_end = vg_start + this->n_vars(s,vg);
1207  if (var < vg_end)
1208  {
1209  offset = var - vg_start;
1210  return returnval;
1211  }
1212  vg_start = vg_end;
1213  }
1214 }
1215 
1216 
1217 
1218 inline
1219 bool DofObject::has_dofs (const unsigned int sys) const
1220 {
1221  if (sys == libMesh::invalid_uint)
1222  {
1223  for (auto s : make_range(this->n_systems()))
1224  if (this->n_vars(s))
1225  return true;
1226  }
1227 
1228  else
1229  {
1230  libmesh_assert_less (sys, this->n_systems());
1231 
1232  if (this->n_vars(sys))
1233  return true;
1234  }
1235 
1236  return false;
1237 }
1238 
1239 
1240 
1241 inline
1242 unsigned int DofObject::start_idx (const unsigned int s) const
1243 {
1244  libmesh_assert_less (s, this->n_systems());
1245  libmesh_assert_less (s, _idx_buf.size());
1246 
1247  return cast_int<unsigned int>(std::abs(dof_id_signed_type(_idx_buf[s])));
1248 }
1249 
1250 
1251 
1252 inline
1253 unsigned int DofObject::end_idx (const unsigned int s) const
1254 {
1255  libmesh_assert_less (s, this->n_systems());
1256  libmesh_assert_less (s, _idx_buf.size());
1257 
1258  return ((s+1) == this->n_pseudo_systems()) ?
1259  cast_int<unsigned int>(_idx_buf.size()) :
1260  cast_int<unsigned int>(_idx_buf[s+1]);
1261 }
1262 
1263 
1264 
1265 inline
1266 unsigned int DofObject::start_idx_ints () const
1267 {
1268  libmesh_assert (this->has_extra_integers());
1269 
1270  unsigned int n_sys = this->n_systems();
1271 
1272  libmesh_assert_less(this->n_systems(), _idx_buf.size());
1273  return n_sys ? cast_int<unsigned int>(_idx_buf[this->n_systems()]) :
1274  (n_sys+1);
1275 }
1276 
1277 
1278 
1279 inline
1280 unsigned int DofObject::end_idx_ints () const
1281 {
1282  libmesh_assert (this->has_extra_integers());
1283 
1284  return cast_int<unsigned int>(_idx_buf.size());
1285 }
1286 
1287 
1288 
1289 inline
1290 void DofObject::set_vg_dof_base(const unsigned int s,
1291  const unsigned int vg,
1292  const dof_id_type db)
1293 {
1294  libmesh_assert_less (s, this->n_systems());
1295  libmesh_assert_less (vg, this->n_var_groups(s));
1296 
1297  const unsigned int
1298  start_idx_sys = this->start_idx(s);
1299 
1300  libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
1301 
1302  _idx_buf[start_idx_sys + 2*vg + 1] = db;
1303 
1304  libmesh_assert_equal_to (this->vg_dof_base(s,vg), db);
1305 }
1306 
1307 
1308 
1309 inline
1311  const unsigned int vg) const
1312 {
1313  libmesh_assert_less (s, this->n_systems());
1314  libmesh_assert_less (vg, this->n_var_groups(s));
1315 
1316  const unsigned int
1317  start_idx_sys = this->start_idx(s);
1318 
1319  libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
1320 
1321  // #ifdef DEBUG
1322  // std::cout << " [ ";
1323  // for (auto i : _idx_buf)
1324  // std::cout << i << " ";
1325  // std::cout << "]\n";
1326  // #endif
1327 
1328  return _idx_buf[start_idx_sys + 2*vg + 1];
1329 }
1330 
1331 
1332 
1333 inline
1334 unsigned int DofObject::var_to_vg (const unsigned int s,
1335  const unsigned int var) const
1336 {
1337  const unsigned int
1338  nvg = this->n_var_groups(s);
1339 
1340  for (unsigned int vg=0, vg_end=0; vg<nvg; vg++)
1341  {
1342  vg_end += this->n_vars(s,vg);
1343  if (var < vg_end) return vg;
1344  }
1345 
1346  libmesh_error_msg("Error: could not map variable " << var << " to variable group.");
1347 }
1348 
1349 
1350 
1351 inline
1352 unsigned int DofObject::system_var_to_vg_var (const unsigned int s,
1353  const unsigned int vg,
1354  const unsigned int var) const
1355 {
1356  unsigned int accumulated_sum=0;
1357 
1358  for (unsigned int vgc=0; vgc<vg; vgc++)
1359  accumulated_sum += this->n_vars(s,vgc);
1360 
1361  libmesh_assert_less_equal (accumulated_sum, var);
1362 
1363  return (var - accumulated_sum);
1364 }
1365 
1372 {
1373  bool operator()(const DofObject * a,
1374  const DofObject * b) const
1375  {
1376  libmesh_assert (a);
1377  libmesh_assert (b);
1378 
1379  return a->id() < b->id();
1380  }
1381 };
1382 
1384 {
1385  bool operator()(const DofObject * a,
1386  const DofObject * b) const
1387  {
1388  libmesh_assert (a);
1389  libmesh_assert (b);
1390 
1391  if (a->processor_id() < b->processor_id())
1392  return true;
1393  if (b->processor_id() < a->processor_id())
1394  return false;
1395 
1396  return a->id() < b->id();
1397  }
1398 };
1399 
1400 } // namespace libMesh
1401 
1402 
1403 #endif // #ifndef LIBMESH_DOF_OBJECT_H
unsigned int n_comp_group(const unsigned int s, const unsigned int vg) const
Definition: dof_object.h:1008
bool has_dofs(const unsigned int s=libMesh::invalid_uint) const
Definition: dof_object.h:1219
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
unique_id_type & set_unique_id()
Definition: dof_object.h:852
bool valid_id() const
Definition: dof_object.h:878
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:736
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:793
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:1371
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:1139
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:254
unsigned int n_vars(const unsigned int s, const unsigned int vg) const
Definition: dof_object.h:960
bool has_extra_integers() const
Returns whether extra integers are associated to the DofObject.
Definition: dof_object.h:1181
bool operator()(const DofObject *a, const DofObject *b) const
Definition: dof_object.h:1373
void set_id(const dof_id_type dofid)
Sets the id for this DofObject.
Definition: dof_object.h:196
unsigned int n_dofs(const unsigned int s, const unsigned int var=libMesh::invalid_uint) const
Definition: dof_object.h:801
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
Definition: dof_object.h:1025
dof_id_type _id
The id of the DofObject.
Definition: dof_object.h:578
void invalidate()
Invalidates all the indices for this DofObject.
Definition: dof_object.h:783
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:1352
std::pair< unsigned int, unsigned int > var_to_vg_and_offset(const unsigned int s, const unsigned int var) const
Definition: dof_object.h:1193
const DofObject * get_old_dof_object() const
Definition: dof_object.h:97
void print_dof_info() const
Print out info for debugging.
Definition: dof_object.C:670
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:1290
const DofObject & get_old_dof_object_ref() const
Definition: dof_object.h:110
uint8_t processor_id_type
Definition: id_types.h:104
dof_id_type & set_id()
Definition: dof_object.h:831
bool valid_unique_id() const
Definition: dof_object.h:886
unsigned int end_idx(const unsigned int s) const
The ending index for system s.
Definition: dof_object.h:1253
DofObject()
Constructor.
Definition: dof_object.h:722
dof_id_type index_t
DoF index information.
Definition: dof_object.h:673
unique_id_type _unique_id
A globally unique id, guaranteed not to change as the mesh is repartitioned or adapted.
Definition: dof_object.h:572
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的绝对值。
Definition: type_vector.h:112
void add_system()
Adds an additional system to the DofObject.
Definition: dof_object.C:195
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
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:1310
unsigned int n_extra_integers() const
Returns how many extra integers are associated to the DofObject.
Definition: dof_object.h:1163
bool valid_processor_id() const
Definition: dof_object.h:922
void libmesh_ignore(const Args &...)
void set_buffer(const std::vector< dof_id_type > &buf)
Definition: dof_object.h:712
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:482
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:488
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 n_var_groups(const unsigned int s) const
Definition: dof_object.h:950
processor_id_type _processor_id
The local processor id.
Definition: libmesh.C:239
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:767
bool operator()(const DofObject *a, const DofObject *b) const
Definition: dof_object.h:1385
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:477
int8_t dof_id_signed_type
Definition: id_types.h:68
unsigned int n_pseudo_systems() const
Definition: dof_object.h:940
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:1119
unsigned int start_idx(const unsigned int s) const
The starting index for system s.
Definition: dof_object.h:1242
DofObject * get_old_dof_object()
Pointer accessor for previously public old_dof_object.
Definition: dof_object.h:96
This class implements reference counting.
void invalidate_processor_id()
Sets the processor id to invalid_processor_id.
Definition: dof_object.h:775
std::vector< index_t > index_buffer_t
Definition: dof_object.h:674
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
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
void set_n_systems(const unsigned int s)
Sets the number of systems for this DofObject.
Definition: dof_object.C:150
~DofObject()=default
Destructor.
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:1334
unsigned int start_idx_ints() const
The starting index for an extra_integers pseudosystem.
Definition: dof_object.h:1266
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
std::unique_ptr< DofObject > old_dof_object
This object on the last mesh.
Definition: dof_object.h:88
void invalidate_dofs(const unsigned int sys_num=libMesh::invalid_uint)
Sets all degree of freedom numbers to invalid_id.
Definition: dof_object.h:746
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
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:1095
index_buffer_t _idx_buf
Definition: dof_object.h:675
unsigned int n_comp(const unsigned int s, const unsigned int var) const
Definition: dof_object.h:995
dof_id_type id() const
Definition: dof_object.h:823
unsigned int n_systems() const
Definition: dof_object.h:930
void debug_buffer() const
Print our buffer for debugging.
Definition: dof_object.C:660
unique_id_type unique_id() const
Definition: dof_object.h:839
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:589
static const index_t ncv_magic_exp
Definition: dof_object.h:687
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:1079
unsigned int end_idx_ints() const
The ending index for an extra_integers pseudosystem.
Definition: dof_object.h:1280
uint8_t dof_id_type
Definition: id_types.h:67
processor_id_type processor_id() const
Definition: dof_object.h:898
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:686