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
682 static const index_t ncv_magic = 256; // = 2^8, in case we want to manually bitshift
683 static const index_t ncv_magic_exp = 8; // Let's manually bitshift
684
688 unsigned int start_idx(const unsigned int s) const;
689
693 unsigned int end_idx(const unsigned int s) const;
694
698 unsigned int start_idx_ints() const;
699
703 unsigned int end_idx_ints() const;
704
705 // methods only available for unit testing
706#ifdef LIBMESH_IS_UNIT_TESTING
707public:
708 void set_buffer (const std::vector<dof_id_type> & buf)
709 { _idx_buf = buf; }
710#endif
711};
712
713
714
715//------------------------------------------------------
716// Inline functions
717inline
719#ifdef LIBMESH_ENABLE_UNIQUE_ID
720 _unique_id (invalid_unique_id),
721#endif
722 _id (invalid_id),
723 _processor_id (invalid_processor_id)
724{
725 this->invalidate();
726}
727
728
729
730inline
731std::unique_ptr<DofObject>
733{
734 return other
735 ? std::unique_ptr<DofObject>(new DofObject(*other))
736 : std::unique_ptr<DofObject>(new DofObject());
737}
738
739
740
741inline
742void DofObject::invalidate_dofs (const unsigned int sys_num)
743{
744 const unsigned int n_sys = this->n_systems();
745 // If the user does not specify the system number...
746 if (sys_num >= n_sys)
747 {
748 for (auto s : make_range(n_sys))
749 for (auto vg : make_range(this->n_var_groups(s)))
750 if (this->n_comp_group(s,vg))
751 this->set_vg_dof_base(s,vg,invalid_id);
752 }
753 // ...otherwise invalidate the dofs for all systems
754 else
755 for (auto vg : make_range(this->n_var_groups(sys_num)))
756 if (this->n_comp_group(sys_num,vg))
757 this->set_vg_dof_base(sys_num,vg,invalid_id);
758}
759
760
761
762inline
764{
765 this->set_id (invalid_id);
766}
767
768
769
770inline
775
776
777
778inline
780{
781 this->invalidate_dofs ();
782 this->invalidate_id ();
784}
785
786
787
788inline
790{
791 this->set_n_systems(0);
792}
793
794
795
796inline
797unsigned int DofObject::n_dofs (const unsigned int s,
798 const unsigned int var) const
799{
800 libmesh_assert_less (s, this->n_systems());
801
802 unsigned int num = 0;
803
804 // Count all variables
805 if (var == libMesh::invalid_uint)
806 for (auto v : make_range(this->n_vars(s)))
807 num += this->n_comp(s,v);
808
809 // Only count specified variable
810 else
811 num = this->n_comp(s,var);
812
813 return num;
814}
815
816
817
818inline
820{
821 return _id;
822}
823
824
825
826inline
828{
829 return _id;
830}
831
832
833
834inline
836{
837#ifdef LIBMESH_ENABLE_UNIQUE_ID
839 return _unique_id;
840#else
841 return invalid_unique_id;
842#endif
843}
844
845
846
847inline
849{
850#ifdef LIBMESH_ENABLE_UNIQUE_ID
851 _unique_id = new_id;
852#else
853 libmesh_ignore(new_id);
854 libmesh_not_implemented();
855#endif
856}
857
858
859
860inline
862{
863 return (DofObject::invalid_id != _id);
864}
865
866
867
868inline
870{
871#ifdef LIBMESH_ENABLE_UNIQUE_ID
873#else
874 return false;
875#endif
876}
877
878
879
880inline
885
886
887
888inline
893
894
895
896inline
898{
899 this->processor_id() = pid;
900}
901
902
903
904inline
909
910
911
912inline
913unsigned int DofObject::n_systems () const
914{
915 const int hdr = _idx_buf.empty() ?
916 0 : cast_int<int>(dof_id_signed_type(_idx_buf[0]));
917 return hdr >= 0 ? hdr : (-hdr-1);
918}
919
920
921
922inline
923unsigned int DofObject::n_pseudo_systems () const
924{
925 const int hdr = _idx_buf.empty() ?
926 0 : cast_int<int>(dof_id_signed_type(_idx_buf[0]));
927 return std::abs(hdr);
928}
929
930
931
932inline
933unsigned int DofObject::n_var_groups(const unsigned int s) const
934{
935 libmesh_assert_less (s, this->n_systems());
936
937 return (this->end_idx(s) - this->start_idx(s)) / 2;
938}
939
940
941
942inline
943unsigned int DofObject::n_vars(const unsigned int s,
944 const unsigned int vg) const
945{
946 libmesh_assert_less (s, this->n_systems());
947 libmesh_assert_less (vg, this->n_var_groups(s));
948
949 const unsigned int start_idx_sys = this->start_idx(s);
950
951 libmesh_assert_less ((start_idx_sys + 2*vg), _idx_buf.size());
952
953 return (cast_int<unsigned int>
954 (_idx_buf[start_idx_sys + 2*vg]) >> ncv_magic_exp);
955}
956
957
958
959inline
960unsigned int DofObject::n_vars(const unsigned int s) const
961{
962 libmesh_assert_less (s, this->n_systems());
963
964 const unsigned int nvg = this->n_var_groups(s);
965
966 unsigned int val=0;
967
968 for (unsigned int vg=0; vg<nvg; vg++)
969 val += this->n_vars(s,vg);
970
971 return val;
972}
973
974
975
976
977inline
978unsigned int DofObject::n_comp(const unsigned int s,
979 const unsigned int var) const
980{
981 libmesh_assert_less (s, this->n_systems());
982 libmesh_assert_less (var, this->n_vars(s));
983
984 return this->n_comp_group(s,this->var_to_vg(s,var));
985}
986
987
988
989
990inline
991unsigned int DofObject::n_comp_group(const unsigned int s,
992 const unsigned int vg) const
993{
994 libmesh_assert_less (s, this->n_systems());
995 libmesh_assert_less (vg, this->n_var_groups(s));
996
997 const unsigned int
998 start_idx_sys = this->start_idx(s);
999
1000 libmesh_assert_less ((start_idx_sys + 2*vg), _idx_buf.size());
1001
1002 return (_idx_buf[start_idx_sys + 2*vg] % ncv_magic);
1003}
1004
1005
1006
1007inline
1009 const unsigned int var,
1010 const unsigned int comp) const
1011{
1012 libmesh_assert_less (s, this->n_systems());
1013 libmesh_assert_less (var, this->n_vars(s));
1014 libmesh_assert_less (comp, this->n_comp(s,var));
1015
1016 const std::pair<unsigned int, unsigned int>
1017 vg_vig = this->var_to_vg_and_offset(s,var);
1018
1019 const unsigned int
1020 n_comp = this->n_comp_group(s,vg_vig.first);
1021
1022 return this->dof_number(s, vg_vig.first, vg_vig.second,
1023 comp, n_comp);
1024}
1025
1026
1027
1028inline
1030 const unsigned int vg,
1031 const unsigned int vig,
1032 const unsigned int comp,
1033 const unsigned int n_comp) const
1034{
1035 libmesh_assert_less (s, this->n_systems());
1036 libmesh_assert_less (vg, this->n_var_groups(s));
1037 libmesh_assert_less (vig, this->n_vars(s,vg));
1038
1039 const unsigned int
1040 start_idx_sys = this->start_idx(s);
1041
1042 libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
1043
1044 const dof_id_type
1045 base_idx = _idx_buf[start_idx_sys + 2*vg + 1];
1046
1047 // if the first component is invalid, they
1048 // are all invalid
1049 if (base_idx == invalid_id)
1050 return invalid_id;
1051
1052 // otherwise the index is the first component
1053 // index augmented by the component number
1054 else
1055 return cast_int<dof_id_type>(base_idx + vig*n_comp + comp);
1056}
1057
1058
1059
1060inline
1061void
1062DofObject::set_extra_integer(const unsigned int index,
1063 const dof_id_type value)
1064{
1065 libmesh_assert_less(index, this->n_extra_integers());
1066 libmesh_assert_less(this->n_pseudo_systems(), _idx_buf.size());
1067
1068 const unsigned int start_idx_i = this->start_idx_ints();
1069
1070 libmesh_assert_less(start_idx_i+index, _idx_buf.size());
1071 _idx_buf[start_idx_i+index] = value;
1072}
1073
1074
1075
1076inline
1078DofObject::get_extra_integer (const unsigned int index) const
1079{
1080 libmesh_assert_less(index, this->n_extra_integers());
1081 libmesh_assert_less(this->n_systems(), _idx_buf.size());
1082
1083 const unsigned int start_idx_i = this->start_idx_ints();
1084
1085 libmesh_assert_less(start_idx_i+index, _idx_buf.size());
1086 return _idx_buf[start_idx_i+index];
1087}
1088
1089
1090
1091// If we're using a type T that's a class with no trivial
1092// copy-assignment, -Wclass-memaccess will scream about doing it with
1093// memcpy, even if (as with boost::multiprecision::float128) this is a
1094// false positive.
1095#include "libmesh/ignore_warnings.h"
1096
1097
1098
1099template <typename T>
1100inline
1101void
1102DofObject::set_extra_datum(const unsigned int index,
1103 const T value)
1104{
1105#ifndef NDEBUG
1106 const unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
1107#endif
1108 libmesh_assert_less(index+n_more_integers, this->n_extra_integers());
1109 libmesh_assert_less(this->n_pseudo_systems(), _idx_buf.size());
1110
1111 const unsigned int start_idx_i = this->start_idx_ints();
1112
1113 libmesh_assert_less(start_idx_i+index+n_more_integers, _idx_buf.size());
1114 std::memcpy(&_idx_buf[start_idx_i+index], &value, sizeof(T));
1115}
1116
1117
1118
1119template <typename T>
1120inline
1121T
1122DofObject::get_extra_datum (const unsigned int index) const
1123{
1124#ifndef NDEBUG
1125 const unsigned int n_more_integers = (sizeof(T)-1)/sizeof(dof_id_type);
1126#endif
1127 libmesh_assert_less(index+n_more_integers, this->n_extra_integers());
1128 libmesh_assert_less(this->n_systems(), _idx_buf.size());
1129
1130 const unsigned int start_idx_i = this->start_idx_ints();
1131
1132 libmesh_assert_less(start_idx_i+index+n_more_integers, _idx_buf.size());
1133 T returnval;
1134 std::memcpy(&returnval, &_idx_buf[start_idx_i+index], sizeof(T));
1135 return returnval;
1136}
1137
1138
1139
1140#include "libmesh/restore_warnings.h"
1141
1142
1143
1144inline
1145unsigned int
1147{
1148 if (_idx_buf.empty())
1149 return 0;
1150
1151 const int hdr = dof_id_signed_type(_idx_buf[0]);
1152 if (hdr >= 0)
1153 return 0;
1154
1155 const unsigned int start_idx_i = this->start_idx_ints();
1156
1157 return _idx_buf.size() - start_idx_i;
1158}
1159
1160
1161
1162inline
1163bool
1165{
1166 if (_idx_buf.empty())
1167 return 0;
1168
1169 return (dof_id_signed_type(_idx_buf[0]) < 0);
1170}
1171
1172
1173
1174inline
1175std::pair<unsigned int, unsigned int>
1177 const unsigned int var) const
1178{
1179 std::pair<unsigned int, unsigned int> returnval(0,0);
1180
1181 unsigned int & vg = returnval.first;
1182 unsigned int & offset = returnval.second;
1183
1184 unsigned int vg_start = 0;
1185 for (; ; vg++)
1186 {
1187 libmesh_assert_less(vg, this->n_var_groups(s));
1188
1189 const unsigned int vg_end = vg_start + this->n_vars(s,vg);
1190 if (var < vg_end)
1191 {
1192 offset = var - vg_start;
1193 return returnval;
1194 }
1195 vg_start = vg_end;
1196 }
1197}
1198
1199
1200
1201inline
1202bool DofObject::has_dofs (const unsigned int sys) const
1203{
1204 if (sys == libMesh::invalid_uint)
1205 {
1206 for (auto s : make_range(this->n_systems()))
1207 if (this->n_vars(s))
1208 return true;
1209 }
1210
1211 else
1212 {
1213 libmesh_assert_less (sys, this->n_systems());
1214
1215 if (this->n_vars(sys))
1216 return true;
1217 }
1218
1219 return false;
1220}
1221
1222
1223
1224inline
1225unsigned int DofObject::start_idx (const unsigned int s) const
1226{
1227 libmesh_assert_less (s, this->n_systems());
1228 libmesh_assert_less (s, _idx_buf.size());
1229
1230 return cast_int<unsigned int>(std::abs(dof_id_signed_type(_idx_buf[s])));
1231}
1232
1233
1234
1235inline
1236unsigned int DofObject::end_idx (const unsigned int s) const
1237{
1238 libmesh_assert_less (s, this->n_systems());
1239 libmesh_assert_less (s, _idx_buf.size());
1240
1241 return ((s+1) == this->n_pseudo_systems()) ?
1242 cast_int<unsigned int>(_idx_buf.size()) :
1243 cast_int<unsigned int>(_idx_buf[s+1]);
1244}
1245
1246
1247
1248inline
1249unsigned int DofObject::start_idx_ints () const
1250{
1252
1253 unsigned int n_sys = this->n_systems();
1254
1255 libmesh_assert_less(this->n_systems(), _idx_buf.size());
1256 return n_sys ? cast_int<unsigned int>(_idx_buf[this->n_systems()]) :
1257 (n_sys+1);
1258}
1259
1260
1261
1262inline
1263unsigned int DofObject::end_idx_ints () const
1264{
1266
1267 return cast_int<unsigned int>(_idx_buf.size());
1268}
1269
1270
1271
1272inline
1273void DofObject::set_vg_dof_base(const unsigned int s,
1274 const unsigned int vg,
1275 const dof_id_type db)
1276{
1277 libmesh_assert_less (s, this->n_systems());
1278 libmesh_assert_less (vg, this->n_var_groups(s));
1279
1280 const unsigned int
1281 start_idx_sys = this->start_idx(s);
1282
1283 libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
1284
1285 _idx_buf[start_idx_sys + 2*vg + 1] = db;
1286
1287 libmesh_assert_equal_to (this->vg_dof_base(s,vg), db);
1288}
1289
1290
1291
1292inline
1294 const unsigned int vg) const
1295{
1296 libmesh_assert_less (s, this->n_systems());
1297 libmesh_assert_less (vg, this->n_var_groups(s));
1298
1299 const unsigned int
1300 start_idx_sys = this->start_idx(s);
1301
1302 libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
1303
1304 // #ifdef DEBUG
1305 // std::cout << " [ ";
1306 // for (auto i : _idx_buf)
1307 // std::cout << i << " ";
1308 // std::cout << "]\n";
1309 // #endif
1310
1311 return _idx_buf[start_idx_sys + 2*vg + 1];
1312}
1313
1314
1315
1316inline
1317unsigned int DofObject::var_to_vg (const unsigned int s,
1318 const unsigned int var) const
1319{
1320 const unsigned int
1321 nvg = this->n_var_groups(s);
1322
1323 for (unsigned int vg=0, vg_end=0; vg<nvg; vg++)
1324 {
1325 vg_end += this->n_vars(s,vg);
1326 if (var < vg_end) return vg;
1327 }
1328
1329 libmesh_error_msg("Error: could not map variable " << var << " to variable group.");
1330}
1331
1332
1333
1334inline
1335unsigned int DofObject::system_var_to_vg_var (const unsigned int s,
1336 const unsigned int vg,
1337 const unsigned int var) const
1338{
1339 unsigned int accumulated_sum=0;
1340
1341 for (unsigned int vgc=0; vgc<vg; vgc++)
1342 accumulated_sum += this->n_vars(s,vgc);
1343
1344 libmesh_assert_less_equal (accumulated_sum, var);
1345
1346 return (var - accumulated_sum);
1347}
1348
1355{
1356 bool operator()(const DofObject * a,
1357 const DofObject * b) const
1358 {
1359 libmesh_assert (a);
1360 libmesh_assert (b);
1361
1362 return a->id() < b->id();
1363 }
1364};
1365
1367{
1368 bool operator()(const DofObject * a,
1369 const DofObject * b) const
1370 {
1371 libmesh_assert (a);
1372 libmesh_assert (b);
1373
1374 if (a->processor_id() < b->processor_id())
1375 return true;
1376 if (b->processor_id() < a->processor_id())
1377 return false;
1378
1379 return a->id() < b->id();
1380 }
1381};
1382
1383} // namespace libMesh
1384
1385
1386#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:771
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:913
unsigned int n_comp(const unsigned int s, const unsigned int var) const
Definition dof_object.h:978
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:861
unsigned int n_comp_group(const unsigned int s, const unsigned int vg) const
Definition dof_object.h:991
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
DofObject()
Constructor.
Definition dof_object.h:718
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:763
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:708
void invalidate_dofs(const unsigned int sys_num=libMesh::invalid_uint)
Sets all degree of freedom numbers to invalid_id.
Definition dof_object.h:742
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:881
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:827
unsigned int n_var_groups(const unsigned int s) const
Definition dof_object.h:933
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 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:682
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:835
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:905
void invalidate()
Invalidates all the indices for this DofObject.
Definition dof_object.h:779
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:797
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:869
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:819
static const index_t ncv_magic_exp
Definition dof_object.h:683
~DofObject()=default
Destructor.
unsigned int n_pseudo_systems() const
Definition dof_object.h:923
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:789
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:943
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:732
void set_unique_id(unique_id_type new_id)
Sets the unique_id for this DofObject.
Definition dof_object.h:848
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
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