libMesh
Loading...
Searching...
No Matches
dof_object.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_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
37namespace libMesh
38{
39
40// Forward declarations
41class DofObject;
42
43
54class DofObject : public ReferenceCountedObject<DofObject>
55{
56#ifdef LIBMESH_IS_UNIT_TESTING
57public:
58#else
59protected:
60#endif
61
66 DofObject ();
67
68public:
69
73 ~DofObject () = default;
74
75#ifdef LIBMESH_ENABLE_AMR
76
85#ifndef LIBMESH_ENABLE_DEPRECATED
86protected:
87#endif
88 std::unique_ptr<DofObject> old_dof_object;
89
90public:
97 const DofObject * get_old_dof_object() const { return old_dof_object.get(); }
98
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
151
155 void invalidate ();
156
165 unsigned int n_dofs (const unsigned int s,
166 const unsigned int var =
168
172 dof_id_type id () const;
173
177 dof_id_type & set_id ();
178
182 unique_id_type unique_id () const;
183
187 void set_unique_id (unique_id_type new_id);
188
192 void set_id (const dof_id_type dofid)
193 { this->set_id() = dofid; }
194
199 bool valid_id () const;
200
205 bool valid_unique_id () const;
206
215
221
225 void processor_id (const processor_id_type pid);
226
231 bool valid_processor_id () const;
232
237 unsigned int n_systems() const;
238
244 unsigned int n_pseudo_systems() const;
245
254 void set_n_systems (const unsigned int s);
255
261 void set_extra_integer (const unsigned int index, const dof_id_type value);
262
268 dof_id_type get_extra_integer (const unsigned int index) const;
269
276 template <typename T>
277 void set_extra_datum (const unsigned int index, const T value);
278
285 template <typename T>
286 T get_extra_datum (const unsigned int index) const;
287
288
292 void add_system ();
293
298 unsigned int n_var_groups(const unsigned int s) const;
299
304 unsigned int n_vars(const unsigned int s,
305 const unsigned int vg) const;
306
311 unsigned int n_vars(const unsigned int s) const;
312
320 void set_n_vars_per_group(const unsigned int s,
321 const std::vector<unsigned int> & nvpg);
322
332 unsigned int n_comp(const unsigned int s,
333 const unsigned int var) const;
334
344 unsigned int n_comp_group(const unsigned int s,
345 const unsigned int vg) const;
346
351 void set_n_comp(const unsigned int s,
352 const unsigned int var,
353 const unsigned int ncomp);
354
359 void set_n_comp_group(const unsigned int s,
360 const unsigned int vg,
361 const unsigned int ncomp);
362
371 dof_id_type dof_number(const unsigned int s,
372 const unsigned int var,
373 const unsigned int comp) const;
374
383 dof_id_type dof_number(const unsigned int s,
384 const unsigned int vg,
385 const unsigned int vig,
386 const unsigned int comp,
387 const unsigned int n_comp) const;
388
394 std::pair<unsigned int, unsigned int>
395 var_to_vg_and_offset(const unsigned int s,
396 const unsigned int var) const;
397
402 void set_dof_number(const unsigned int s,
403 const unsigned int var,
404 const unsigned int comp,
405 const dof_id_type dn);
406
411 bool has_dofs(const unsigned int s=libMesh::invalid_uint) const;
412
418 void set_vg_dof_base(const unsigned int s,
419 const unsigned int vg,
420 const dof_id_type db);
421
427 dof_id_type vg_dof_base(const unsigned int s,
428 const unsigned int vg) const;
429
440 void add_extra_integers (const unsigned int n_integers);
441
453 void add_extra_integers (const unsigned int n_integers,
454 const std::vector<dof_id_type> & default_values);
455
463 unsigned int n_extra_integers () const;
464
468 bool has_extra_integers () const;
469
473 static constexpr dof_id_type invalid_id = static_cast<dof_id_type>(-1);
474
478 static constexpr unique_id_type invalid_unique_id = static_cast<unique_id_type>(-1);
479
484 static constexpr processor_id_type invalid_processor_id = static_cast<processor_id_type>(-1);
485
490 unsigned int packed_indexing_size() const;
491
496 static unsigned int unpackable_indexing_size
497 (std::vector<largest_id_type>::const_iterator begin);
498
504 void unpack_indexing(std::vector<largest_id_type>::const_iterator begin);
505
511 void pack_indexing(std::back_insert_iterator<std::vector<largest_id_type>> target) const;
512
516 void debug_buffer () const;
517
521 void print_dof_info() const;
522
523 // Deep copy (or almost-copy) of DofObjects is solely for a couple
524 // tricky internal uses.
525private:
526
531 DofObject (const DofObject &);
532
541 std::unique_ptr<DofObject>
542 construct(const DofObject * other = nullptr);
543
547 DofObject & operator= (const DofObject & dof_obj);
548
553 unsigned int var_to_vg (const unsigned int s,
554 const unsigned int var) const;
555
560 unsigned int system_var_to_vg_var (const unsigned int s,
561 const unsigned int vg,
562 const unsigned int var) const;
563
567#ifdef LIBMESH_ENABLE_UNIQUE_ID
569#endif
570
575
586
670 typedef std::vector<index_t> index_buffer_t;
672
696 static constexpr index_t ncv_magic_exp = sizeof(index_t)*3; // To manually bitshift
697 static constexpr index_t ncv_magic = index_t(1) << ncv_magic_exp; // = 2^exp, for bitshifts
698
702 unsigned int start_idx(const unsigned int s) const;
703
707 unsigned int end_idx(const unsigned int s) const;
708
712 unsigned int start_idx_ints() const;
713
717 unsigned int end_idx_ints() const;
718
719 // methods only available for unit testing
720#ifdef LIBMESH_IS_UNIT_TESTING
721public:
722 void set_buffer (const std::vector<dof_id_type> & buf)
723 { _idx_buf = buf; }
724#endif
725};
726
727
728
729//------------------------------------------------------
730// Inline functions
731inline
733#ifdef LIBMESH_ENABLE_UNIQUE_ID
734 _unique_id (invalid_unique_id),
735#endif
736 _id (invalid_id),
737 _processor_id (invalid_processor_id)
738{
739 this->invalidate();
740}
741
742
743
744inline
745std::unique_ptr<DofObject>
747{
748 return other
749 ? std::unique_ptr<DofObject>(new DofObject(*other))
750 : std::unique_ptr<DofObject>(new DofObject());
751}
752
753
754
755inline
756void DofObject::invalidate_dofs (const unsigned int sys_num)
757{
758 const unsigned int n_sys = this->n_systems();
759 // If the user does not specify the system number...
760 if (sys_num >= n_sys)
761 {
762 for (auto s : make_range(n_sys))
763 for (auto vg : make_range(this->n_var_groups(s)))
764 if (this->n_comp_group(s,vg))
765 this->set_vg_dof_base(s,vg,invalid_id);
766 }
767 // ...otherwise invalidate the dofs for all systems
768 else
769 for (auto vg : make_range(this->n_var_groups(sys_num)))
770 if (this->n_comp_group(sys_num,vg))
771 this->set_vg_dof_base(sys_num,vg,invalid_id);
772}
773
774
775
776inline
778{
779 this->set_id (invalid_id);
780}
781
782
783
784inline
789
790
791
792inline
794{
795 this->invalidate_dofs ();
796 this->invalidate_id ();
798}
799
800
801
802inline
804{
805 this->set_n_systems(0);
806}
807
808
809
810inline
811unsigned int DofObject::n_dofs (const unsigned int s,
812 const unsigned int var) const
813{
814 libmesh_assert_less (s, this->n_systems());
815
816 unsigned int num = 0;
817
818 // Count all variables
819 if (var == libMesh::invalid_uint)
820 for (auto v : make_range(this->n_vars(s)))
821 num += this->n_comp(s,v);
822
823 // Only count specified variable
824 else
825 num = this->n_comp(s,var);
826
827 return num;
828}
829
830
831
832inline
834{
835 return _id;
836}
837
838
839
840inline
842{
843 return _id;
844}
845
846
847
848inline
850{
851#ifdef LIBMESH_ENABLE_UNIQUE_ID
853 return _unique_id;
854#else
855 return invalid_unique_id;
856#endif
857}
858
859
860
861inline
863{
864#ifdef LIBMESH_ENABLE_UNIQUE_ID
865 _unique_id = new_id;
866#else
867 libmesh_ignore(new_id);
868 libmesh_not_implemented();
869#endif
870}
871
872
873
874inline
876{
877 return (DofObject::invalid_id != _id);
878}
879
880
881
882inline
884{
885#ifdef LIBMESH_ENABLE_UNIQUE_ID
887#else
888 return false;
889#endif
890}
891
892
893
894inline
899
900
901
902inline
907
908
909
910inline
912{
913 this->processor_id() = pid;
914}
915
916
917
918inline
923
924
925
926inline
927unsigned int DofObject::n_systems () const
928{
929 const int hdr = _idx_buf.empty() ?
930 0 : cast_int<int>(dof_id_signed_type(_idx_buf[0]));
931 return hdr >= 0 ? hdr : (-hdr-1);
932}
933
934
935
936inline
937unsigned int DofObject::n_pseudo_systems () const
938{
939 const int hdr = _idx_buf.empty() ?
940 0 : cast_int<int>(dof_id_signed_type(_idx_buf[0]));
941 return std::abs(hdr);
942}
943
944
945
946inline
947unsigned int DofObject::n_var_groups(const unsigned int s) const
948{
949 libmesh_assert_less (s, this->n_systems());
950
951 return (this->end_idx(s) - this->start_idx(s)) / 2;
952}
953
954
955
956inline
957unsigned int DofObject::n_vars(const unsigned int s,
958 const unsigned int vg) const
959{
960 libmesh_assert_less (s, this->n_systems());
961 libmesh_assert_less (vg, this->n_var_groups(s));
962
963 const unsigned int start_idx_sys = this->start_idx(s);
964
965 libmesh_assert_less ((start_idx_sys + 2*vg), _idx_buf.size());
966
967 return (cast_int<unsigned int>
968 (_idx_buf[start_idx_sys + 2*vg] >> ncv_magic_exp));
969}
970
971
972
973inline
974unsigned int DofObject::n_vars(const unsigned int s) const
975{
976 libmesh_assert_less (s, this->n_systems());
977
978 const unsigned int nvg = this->n_var_groups(s);
979
980 unsigned int val=0;
981
982 for (unsigned int vg=0; vg<nvg; vg++)
983 val += this->n_vars(s,vg);
984
985 return val;
986}
987
988
989
990
991inline
992unsigned int DofObject::n_comp(const unsigned int s,
993 const unsigned int var) const
994{
995 libmesh_assert_less (s, this->n_systems());
996 libmesh_assert_less (var, this->n_vars(s));
997
998 return this->n_comp_group(s,this->var_to_vg(s,var));
999}
1000
1001
1002
1003
1004inline
1005unsigned int DofObject::n_comp_group(const unsigned int s,
1006 const unsigned int vg) const
1007{
1008 libmesh_assert_less (s, this->n_systems());
1009 libmesh_assert_less (vg, this->n_var_groups(s));
1010
1011 const unsigned int
1012 start_idx_sys = this->start_idx(s);
1013
1014 libmesh_assert_less ((start_idx_sys + 2*vg), _idx_buf.size());
1015
1016 return (_idx_buf[start_idx_sys + 2*vg] % ncv_magic);
1017}
1018
1019
1020
1021inline
1023 const unsigned int var,
1024 const unsigned int comp) const
1025{
1026 libmesh_assert_less (s, this->n_systems());
1027 libmesh_assert_less (var, this->n_vars(s));
1028 libmesh_assert_less (comp, this->n_comp(s,var));
1029
1030 const std::pair<unsigned int, unsigned int>
1031 vg_vig = this->var_to_vg_and_offset(s,var);
1032
1033 const unsigned int
1034 n_comp = this->n_comp_group(s,vg_vig.first);
1035
1036 return this->dof_number(s, vg_vig.first, vg_vig.second,
1037 comp, n_comp);
1038}
1039
1040
1041
1042inline
1044 const unsigned int vg,
1045 const unsigned int vig,
1046 const unsigned int comp,
1047 const unsigned int n_comp) const
1048{
1049 libmesh_assert_less (s, this->n_systems());
1050 libmesh_assert_less (vg, this->n_var_groups(s));
1051 libmesh_assert_less (vig, this->n_vars(s,vg));
1052
1053 const unsigned int
1054 start_idx_sys = this->start_idx(s);
1055
1056 libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
1057
1058 const dof_id_type
1059 base_idx = _idx_buf[start_idx_sys + 2*vg + 1];
1060
1061 // if the first component is invalid, they
1062 // are all invalid
1063 if (base_idx == invalid_id)
1064 return invalid_id;
1065
1066 // otherwise the index is the first component
1067 // index augmented by the component number
1068 else
1069 return cast_int<dof_id_type>(base_idx + vig*n_comp + comp);
1070}
1071
1072
1073
1074inline
1075void
1076DofObject::set_extra_integer(const unsigned int index,
1077 const dof_id_type value)
1078{
1079 libmesh_assert_less(index, this->n_extra_integers());
1080 libmesh_assert_less(this->n_pseudo_systems(), _idx_buf.size());
1081
1082 const unsigned int start_idx_i = this->start_idx_ints();
1083
1084 libmesh_assert_less(start_idx_i+index, _idx_buf.size());
1085 _idx_buf[start_idx_i+index] = value;
1086}
1087
1088
1089
1090inline
1092DofObject::get_extra_integer (const unsigned int index) const
1093{
1094 libmesh_assert_less(index, this->n_extra_integers());
1095 libmesh_assert_less(this->n_systems(), _idx_buf.size());
1096
1097 const unsigned int start_idx_i = this->start_idx_ints();
1098
1099 libmesh_assert_less(start_idx_i+index, _idx_buf.size());
1100 return _idx_buf[start_idx_i+index];
1101}
1102
1103
1104
1105// If we're using a type T that's a class with no trivial
1106// copy-assignment, -Wclass-memaccess will scream about doing it with
1107// memcpy, even if (as with boost::multiprecision::float128) this is a
1108// false positive.
1109#include "libmesh/ignore_warnings.h"
1110
1111
1112
1113template <typename T>
1114inline
1115void
1116DofObject::set_extra_datum(const unsigned int index,
1117 const T value)
1118{
1119#ifndef NDEBUG
1120 const unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
1121#endif
1122 libmesh_assert_less(index+n_more_integers, this->n_extra_integers());
1123 libmesh_assert_less(this->n_pseudo_systems(), _idx_buf.size());
1124
1125 const unsigned int start_idx_i = this->start_idx_ints();
1126
1127 libmesh_assert_less(start_idx_i+index+n_more_integers, _idx_buf.size());
1128 std::memcpy(&_idx_buf[start_idx_i+index], &value, sizeof(T));
1129}
1130
1131
1132
1133template <typename T>
1134inline
1135T
1136DofObject::get_extra_datum (const unsigned int index) const
1137{
1138#ifndef NDEBUG
1139 const unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
1140#endif
1141 libmesh_assert_less(index+n_more_integers, this->n_extra_integers());
1142 libmesh_assert_less(this->n_systems(), _idx_buf.size());
1143
1144 const unsigned int start_idx_i = this->start_idx_ints();
1145
1146 libmesh_assert_less(start_idx_i+index+n_more_integers, _idx_buf.size());
1147 T returnval;
1148 std::memcpy(&returnval, &_idx_buf[start_idx_i+index], sizeof(T));
1149 return returnval;
1150}
1151
1152
1153
1154#include "libmesh/restore_warnings.h"
1155
1156
1157
1158inline
1159unsigned int
1161{
1162 if (_idx_buf.empty())
1163 return 0;
1164
1165 const int hdr = dof_id_signed_type(_idx_buf[0]);
1166 if (hdr >= 0)
1167 return 0;
1168
1169 const unsigned int start_idx_i = this->start_idx_ints();
1170
1171 return _idx_buf.size() - start_idx_i;
1172}
1173
1174
1175
1176inline
1177bool
1179{
1180 if (_idx_buf.empty())
1181 return 0;
1182
1183 return (dof_id_signed_type(_idx_buf[0]) < 0);
1184}
1185
1186
1187
1188inline
1189std::pair<unsigned int, unsigned int>
1191 const unsigned int var) const
1192{
1193 std::pair<unsigned int, unsigned int> returnval(0,0);
1194
1195 unsigned int & vg = returnval.first;
1196 unsigned int & offset = returnval.second;
1197
1198 unsigned int vg_start = 0;
1199 for (; ; vg++)
1200 {
1201 libmesh_assert_less(vg, this->n_var_groups(s));
1202
1203 const unsigned int vg_end = vg_start + this->n_vars(s,vg);
1204 if (var < vg_end)
1205 {
1206 offset = var - vg_start;
1207 return returnval;
1208 }
1209 vg_start = vg_end;
1210 }
1211}
1212
1213
1214
1215inline
1216bool DofObject::has_dofs (const unsigned int sys) const
1217{
1218 if (sys == libMesh::invalid_uint)
1219 {
1220 for (auto s : make_range(this->n_systems()))
1221 if (this->n_vars(s))
1222 return true;
1223 }
1224
1225 else
1226 {
1227 libmesh_assert_less (sys, this->n_systems());
1228
1229 if (this->n_vars(sys))
1230 return true;
1231 }
1232
1233 return false;
1234}
1235
1236
1237
1238inline
1239unsigned int DofObject::start_idx (const unsigned int s) const
1240{
1241 libmesh_assert_less (s, this->n_systems());
1242 libmesh_assert_less (s, _idx_buf.size());
1243
1244 return cast_int<unsigned int>(std::abs(dof_id_signed_type(_idx_buf[s])));
1245}
1246
1247
1248
1249inline
1250unsigned int DofObject::end_idx (const unsigned int s) const
1251{
1252 libmesh_assert_less (s, this->n_systems());
1253 libmesh_assert_less (s, _idx_buf.size());
1254
1255 return ((s+1) == this->n_pseudo_systems()) ?
1256 cast_int<unsigned int>(_idx_buf.size()) :
1257 cast_int<unsigned int>(_idx_buf[s+1]);
1258}
1259
1260
1261
1262inline
1263unsigned int DofObject::start_idx_ints () const
1264{
1266
1267 unsigned int n_sys = this->n_systems();
1268
1269 libmesh_assert_less(this->n_systems(), _idx_buf.size());
1270 return n_sys ? cast_int<unsigned int>(_idx_buf[this->n_systems()]) :
1271 (n_sys+1);
1272}
1273
1274
1275
1276inline
1277unsigned int DofObject::end_idx_ints () const
1278{
1280
1281 return cast_int<unsigned int>(_idx_buf.size());
1282}
1283
1284
1285
1286inline
1287void DofObject::set_vg_dof_base(const unsigned int s,
1288 const unsigned int vg,
1289 const dof_id_type db)
1290{
1291 libmesh_assert_less (s, this->n_systems());
1292 libmesh_assert_less (vg, this->n_var_groups(s));
1293
1294 const unsigned int
1295 start_idx_sys = this->start_idx(s);
1296
1297 libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
1298
1299 _idx_buf[start_idx_sys + 2*vg + 1] = db;
1300
1301 libmesh_assert_equal_to (this->vg_dof_base(s,vg), db);
1302}
1303
1304
1305
1306inline
1308 const unsigned int vg) const
1309{
1310 libmesh_assert_less (s, this->n_systems());
1311 libmesh_assert_less (vg, this->n_var_groups(s));
1312
1313 const unsigned int
1314 start_idx_sys = this->start_idx(s);
1315
1316 libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
1317
1318 // #ifdef DEBUG
1319 // std::cout << " [ ";
1320 // for (auto i : _idx_buf)
1321 // std::cout << i << " ";
1322 // std::cout << "]\n";
1323 // #endif
1324
1325 return _idx_buf[start_idx_sys + 2*vg + 1];
1326}
1327
1328
1329
1330inline
1331unsigned int DofObject::var_to_vg (const unsigned int s,
1332 const unsigned int var) const
1333{
1334 const unsigned int
1335 nvg = this->n_var_groups(s);
1336
1337 for (unsigned int vg=0, vg_end=0; vg<nvg; vg++)
1338 {
1339 vg_end += this->n_vars(s,vg);
1340 if (var < vg_end) return vg;
1341 }
1342
1343 libmesh_error_msg("Error: could not map variable " << var << " to variable group.");
1344}
1345
1346
1347
1348inline
1349unsigned int DofObject::system_var_to_vg_var (const unsigned int s,
1350 const unsigned int vg,
1351 const unsigned int var) const
1352{
1353 unsigned int accumulated_sum=0;
1354
1355 for (unsigned int vgc=0; vgc<vg; vgc++)
1356 accumulated_sum += this->n_vars(s,vgc);
1357
1358 libmesh_assert_less_equal (accumulated_sum, var);
1359
1360 return (var - accumulated_sum);
1361}
1362
1369{
1370 bool operator()(const DofObject * a,
1371 const DofObject * b) const
1372 {
1373 libmesh_assert (a);
1374 libmesh_assert (b);
1375
1376 return a->id() < b->id();
1377 }
1378};
1379
1381{
1382 bool operator()(const DofObject * a,
1383 const DofObject * b) const
1384 {
1385 libmesh_assert (a);
1386 libmesh_assert (b);
1387
1388 if (a->processor_id() < b->processor_id())
1389 return true;
1390 if (b->processor_id() < a->processor_id())
1391 return false;
1392
1393 return a->id() < b->id();
1394 }
1395};
1396
1397} // namespace libMesh
1398
1399
1400#endif // #ifndef LIBMESH_DOF_OBJECT_H
unsigned int n_vars
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition dof_object.h:55
unsigned int end_idx(const unsigned int s) const
The ending index for system s.
processor_id_type _processor_id
The processor_id of the DofObject.
Definition dof_object.h:585
void invalidate_processor_id()
Sets the processor id to invalid_processor_id.
Definition dof_object.h:785
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:567
void set_old_dof_object()
Sets the old_dof_object to a copy of this.
Definition dof_object.C:127
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...
unsigned int n_systems() const
Definition dof_object.h:927
unsigned int n_comp(const unsigned int s, const unsigned int var) const
Definition dof_object.h:992
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:377
void set_id(const dof_id_type dofid)
Sets the id for this DofObject.
Definition dof_object.h:192
bool valid_id() const
Definition dof_object.h:875
unsigned int n_comp_group(const unsigned int s, const unsigned int vg) const
unsigned int end_idx_ints() const
The ending index for an extra_integers pseudosystem.
bool has_extra_integers() const
Returns whether extra integers are associated to the DofObject.
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...
const DofObject * get_old_dof_object() const
Definition dof_object.h:97
unsigned int start_idx_ints() const
The starting index for an extra_integers pseudosystem.
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:389
static constexpr index_t ncv_magic
Definition dof_object.h:697
DofObject()
Constructor.
Definition dof_object.h:732
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
void debug_buffer() const
Print our buffer for debugging.
Definition dof_object.C:652
unsigned int n_extra_integers() const
Returns how many extra integers are associated to the DofObject.
std::pair< unsigned int, unsigned int > var_to_vg_and_offset(const unsigned int s, const unsigned int var) const
dof_id_type _id
The id of the DofObject.
Definition dof_object.h:574
void invalidate_id()
Sets the id to invalid_id.
Definition dof_object.h:777
void print_dof_info() const
Print out info for debugging.
Definition dof_object.C:662
std::vector< index_t > index_buffer_t
Definition dof_object.h:670
void set_buffer(const std::vector< dof_id_type > &buf)
Definition dof_object.h:722
void invalidate_dofs(const unsigned int sys_num=libMesh::invalid_uint)
Sets all degree of freedom numbers to invalid_id.
Definition dof_object.h:756
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:239
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.
void add_system()
Adds an additional system to the DofObject.
Definition dof_object.C:187
processor_id_type processor_id() const
Definition dof_object.h:895
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:446
dof_id_type & set_id()
Definition dof_object.h:841
unsigned int n_var_groups(const unsigned int s) const
Definition dof_object.h:947
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.
DofObject & operator=(const DofObject &dof_obj)
Deep-copying assignment operator.
Definition dof_object.C:69
void add_extra_integers(const unsigned int n_integers)
Assigns a set of extra integers to this DofObject.
Definition dof_object.C:482
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition dof_object.h:473
unique_id_type unique_id() const
Definition dof_object.h:849
index_buffer_t _idx_buf
Definition dof_object.h:671
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:634
static constexpr unique_id_type invalid_unique_id
An invalid unique_id to distinguish an uninitialized DofObject.
Definition dof_object.h:478
std::unique_ptr< DofObject > old_dof_object
This object on the last mesh.
Definition dof_object.h:88
bool valid_processor_id() const
Definition dof_object.h:919
void invalidate()
Invalidates all the indices for this DofObject.
Definition dof_object.h:793
DofObject * get_old_dof_object()
Pointer accessor for previously public old_dof_object.
Definition dof_object.h:96
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...
unsigned int n_dofs(const unsigned int s, const unsigned int var=libMesh::invalid_uint) const
Definition dof_object.h:811
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 start_idx(const unsigned int s) const
The starting index for system s.
unique_id_type _unique_id
A globally unique id, guaranteed not to change as the mesh is repartitioned or adapted.
Definition dof_object.h:568
bool valid_unique_id() const
Definition dof_object.h:883
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...
dof_id_type id() const
Definition dof_object.h:833
~DofObject()=default
Destructor.
unsigned int n_pseudo_systems() const
Definition dof_object.h:937
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...
dof_id_type index_t
DoF index information.
Definition dof_object.h:669
void clear_dofs()
Clear the DofMap data structures holding degree of freedom data.
Definition dof_object.h:803
const DofObject & get_old_dof_object_ref() const
Definition dof_object.h:110
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
unsigned int n_vars(const unsigned int s, const unsigned int vg) const
Definition dof_object.h:957
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:746
void set_unique_id(unique_id_type new_id)
Sets the unique_id for this DofObject.
Definition dof_object.h:862
void clear_old_dof_object()
Sets the old_dof_object to nullptr.
Definition dof_object.C:120
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...
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:552
void set_n_systems(const unsigned int s)
Sets the number of systems for this DofObject.
Definition dof_object.C:142
static constexpr index_t ncv_magic_exp
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:696
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:587
bool has_dofs(const unsigned int s=libMesh::invalid_uint) const
This class implements reference counting.
static const Real b
The libMesh namespace provides an interface to certain functionality in the library.
uint8_t unique_id_type
Definition id_types.h:86
void libmesh_ignore(const Args &...)
int8_t dof_id_signed_type
Definition id_types.h:68
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
uint8_t dof_id_type
Definition id_types.h:67
uint8_t processor_id_type
Definition id_types.h:104
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:176
Comparison object to use with DofObject pointers.
bool operator()(const DofObject *a, const DofObject *b) const
bool operator()(const DofObject *a, const DofObject *b) const
static const bool value
Definition xdr_io.C:55