20 #ifndef LIBMESH_DOF_OBJECT_H 21 #define LIBMESH_DOF_OBJECT_H 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" 29 #include "libmesh/reference_counted_object.h" 56 #ifdef LIBMESH_IS_UNIT_TESTING 75 #ifdef LIBMESH_ENABLE_AMR 85 #ifndef LIBMESH_ENABLE_DEPRECATED 165 unsigned int n_dofs (
const unsigned int s,
166 const unsigned int var =
184 #ifdef LIBMESH_ENABLE_DEPRECATED 191 #endif // LIBMESH_ENABLE_DEPRECATED 202 { this->
set_id() = dofid; }
285 template <
typename T>
294 template <
typename T>
313 unsigned int n_vars(
const unsigned int s,
314 const unsigned int vg)
const;
320 unsigned int n_vars(
const unsigned int s)
const;
330 const std::vector<unsigned int> & nvpg);
341 unsigned int n_comp(
const unsigned int s,
342 const unsigned int var)
const;
354 const unsigned int vg)
const;
361 const unsigned int var,
362 const unsigned int ncomp);
369 const unsigned int vg,
370 const unsigned int ncomp);
381 const unsigned int var,
382 const unsigned int comp)
const;
393 const unsigned int vg,
394 const unsigned int vig,
395 const unsigned int comp,
396 const unsigned int n_comp)
const;
403 std::pair<unsigned int, unsigned int>
405 const unsigned int var)
const;
412 const unsigned int var,
413 const unsigned int comp,
428 const unsigned int vg,
437 const unsigned int vg)
const;
463 const std::vector<dof_id_type> & default_values);
506 (std::vector<largest_id_type>::const_iterator begin);
513 void unpack_indexing(std::vector<largest_id_type>::const_iterator begin);
520 void pack_indexing(std::back_insert_iterator<std::vector<largest_id_type>> target)
const;
550 std::unique_ptr<DofObject>
562 unsigned int var_to_vg (
const unsigned int s,
563 const unsigned int var)
const;
570 const unsigned int vg,
571 const unsigned int var)
const;
576 #ifdef LIBMESH_ENABLE_UNIQUE_ID 697 unsigned int start_idx(
const unsigned int s)
const;
702 unsigned int end_idx(
const unsigned int s)
const;
715 #ifdef LIBMESH_IS_UNIT_TESTING 728 #ifdef LIBMESH_ENABLE_UNIQUE_ID
729 _unique_id (invalid_unique_id),
740 std::unique_ptr<DofObject>
744 ? std::unique_ptr<DofObject>(
new DofObject(*other))
745 : std::unique_ptr<DofObject>(
new DofObject());
753 const unsigned int n_sys = this->
n_systems();
755 if (sys_num >= n_sys)
807 const unsigned int var)
const 809 libmesh_assert_less (s, this->
n_systems());
811 unsigned int num = 0;
820 num = this->
n_comp(s,var);
846 #ifdef LIBMESH_ENABLE_UNIQUE_ID 856 #ifdef LIBMESH_ENABLE_DEPRECATED 860 #ifdef LIBMESH_ENABLE_UNIQUE_ID 861 libmesh_deprecated();
864 libmesh_not_implemented();
867 #endif // LIBMESH_ENABLE_DEPRECATED 874 #ifdef LIBMESH_ENABLE_UNIQUE_ID 878 libmesh_not_implemented();
895 #ifdef LIBMESH_ENABLE_UNIQUE_ID 941 return hdr >= 0 ? hdr : (-hdr-1);
951 return std::abs(hdr);
959 libmesh_assert_less (s, this->
n_systems());
968 const unsigned int vg)
const 970 libmesh_assert_less (s, this->
n_systems());
973 const unsigned int start_idx_sys = this->
start_idx(s);
975 libmesh_assert_less ((start_idx_sys + 2*vg),
_idx_buf.size());
977 return (cast_int<unsigned int>
986 libmesh_assert_less (s, this->
n_systems());
992 for (
unsigned int vg=0; vg<nvg; vg++)
993 val += this->
n_vars(s,vg);
1003 const unsigned int var)
const 1005 libmesh_assert_less (s, this->
n_systems());
1006 libmesh_assert_less (var, this->
n_vars(s));
1016 const unsigned int vg)
const 1018 libmesh_assert_less (s, this->
n_systems());
1024 libmesh_assert_less ((start_idx_sys + 2*vg),
_idx_buf.size());
1033 const unsigned int var,
1034 const unsigned int comp)
const 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));
1040 const std::pair<unsigned int, unsigned int>
1046 return this->
dof_number(s, vg_vig.first, vg_vig.second,
1054 const unsigned int vg,
1055 const unsigned int vig,
1056 const unsigned int comp,
1057 const unsigned int n_comp)
const 1059 libmesh_assert_less (s, this->
n_systems());
1061 libmesh_assert_less (vig, this->
n_vars(s,vg));
1066 libmesh_assert_less ((start_idx_sys + 2*vg + 1),
_idx_buf.size());
1069 base_idx =
_idx_buf[start_idx_sys + 2*vg + 1];
1079 return cast_int<dof_id_type>(base_idx + vig*
n_comp + comp);
1094 libmesh_assert_less(start_idx_i+index,
_idx_buf.size());
1109 libmesh_assert_less(start_idx_i+index,
_idx_buf.size());
1110 return _idx_buf[start_idx_i+index];
1119 #include "libmesh/ignore_warnings.h" 1123 template <
typename T>
1130 const unsigned int n_more_integers = (
sizeof(T)-1)/
sizeof(
dof_id_type);
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));
1143 template <
typename T>
1149 const unsigned int n_more_integers = (
sizeof(T)-1)/
sizeof(
dof_id_type);
1156 libmesh_assert_less(start_idx_i+index+n_more_integers,
_idx_buf.size());
1158 std::memcpy(&returnval, &
_idx_buf[start_idx_i+index],
sizeof(T));
1164 #include "libmesh/restore_warnings.h" 1181 return _idx_buf.size() - start_idx_i;
1199 std::pair<unsigned int, unsigned int>
1201 const unsigned int var)
const 1203 std::pair<unsigned int, unsigned int> returnval(0,0);
1205 unsigned int & vg = returnval.first;
1206 unsigned int & offset = returnval.second;
1208 unsigned int vg_start = 0;
1213 const unsigned int vg_end = vg_start + this->
n_vars(s,vg);
1216 offset = var - vg_start;
1237 libmesh_assert_less (sys, this->
n_systems());
1251 libmesh_assert_less (s, this->
n_systems());
1252 libmesh_assert_less (s,
_idx_buf.size());
1262 libmesh_assert_less (s, this->
n_systems());
1263 libmesh_assert_less (s,
_idx_buf.size());
1266 cast_int<unsigned int>(
_idx_buf.size()) :
1267 cast_int<unsigned int>(
_idx_buf[s+1]);
1291 return cast_int<unsigned int>(
_idx_buf.size());
1298 const unsigned int vg,
1301 libmesh_assert_less (s, this->
n_systems());
1307 libmesh_assert_less ((start_idx_sys + 2*vg + 1),
_idx_buf.size());
1309 _idx_buf[start_idx_sys + 2*vg + 1] = db;
1311 libmesh_assert_equal_to (this->
vg_dof_base(s,vg), db);
1318 const unsigned int vg)
const 1320 libmesh_assert_less (s, this->
n_systems());
1326 libmesh_assert_less ((start_idx_sys + 2*vg + 1),
_idx_buf.size());
1335 return _idx_buf[start_idx_sys + 2*vg + 1];
1342 const unsigned int var)
const 1347 for (
unsigned int vg=0, vg_end=0; vg<nvg; vg++)
1349 vg_end += this->
n_vars(s,vg);
1350 if (var < vg_end)
return vg;
1353 libmesh_error_msg(
"Error: could not map variable " << var <<
" to variable group.");
1360 const unsigned int vg,
1361 const unsigned int var)
const 1363 unsigned int accumulated_sum=0;
1365 for (
unsigned int vgc=0; vgc<vg; vgc++)
1366 accumulated_sum += this->
n_vars(s,vgc);
1368 libmesh_assert_less_equal (accumulated_sum, var);
1370 return (var - accumulated_sum);
1386 return a->
id() < b->
id();
1403 return a->
id() < b->
id();
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.
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...
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...
unique_id_type & set_unique_id()
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
std::unique_ptr< DofObject > construct(const DofObject *other=nullptr)
Convenient factory function that calls either the (deep) copy constructor or the default constructor ...
void set_old_dof_object()
Sets the old_dof_object to a copy of this.
void clear_dofs()
Clear the DofMap data structures holding degree of freedom data.
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 ...
Comparison object to use with DofObject pointers.
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
unsigned int n_comp(const unsigned int s, const unsigned int var) const
unsigned int n_var_groups(const unsigned int s) const
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...
bool operator()(const DofObject *a, const DofObject *b) const
void set_id(const dof_id_type dofid)
Sets the id for this DofObject.
unsigned int n_pseudo_systems() const
unique_id_type unique_id() const
dof_id_type _id
The id of the DofObject.
void invalidate()
Invalidates all the indices for this DofObject.
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...
The libMesh namespace provides an interface to certain functionality in the library.
bool has_dofs(const unsigned int s=libMesh::invalid_uint) const
uint8_t processor_id_type
unsigned int start_idx_ints() const
The starting index for an extra_integers pseudosystem.
dof_id_type index_t
DoF index information.
unique_id_type _unique_id
A globally unique id, guaranteed not to change as the mesh is repartitioned or adapted.
unsigned int n_dofs(const unsigned int s, const unsigned int var=libMesh::invalid_uint) const
void add_system()
Adds an additional system to the DofObject.
unsigned int end_idx(const unsigned int s) const
The ending index for system s.
void libmesh_ignore(const Args &...)
void set_buffer(const std::vector< dof_id_type > &buf)
DofObject & operator=(const DofObject &dof_obj)
Deep-copying assignment operator.
static const unique_id_type invalid_unique_id
An invalid unique_id to distinguish an uninitialized DofObject.
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
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...
unsigned int end_idx_ints() const
The ending index for an extra_integers pseudosystem.
unsigned int n_vars(const unsigned int s, const unsigned int vg) const
unsigned int n_systems() const
processor_id_type _processor_id
The local processor id.
void print_dof_info() const
Print out info for debugging.
bool valid_processor_id() const
void clear_old_dof_object()
Sets the old_dof_object to nullptr.
void invalidate_id()
Sets the id to invalid_id.
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
int8_t dof_id_signed_type
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...
bool valid_unique_id() const
DofObject * get_old_dof_object()
Pointer accessor for previously public old_dof_object.
bool has_extra_integers() const
Returns whether extra integers are associated to the DofObject.
const DofObject & get_old_dof_object_ref() const
This class implements reference counting.
void invalidate_processor_id()
Sets the processor id to invalid_processor_id.
std::vector< index_t > index_buffer_t
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...
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...
void set_n_systems(const unsigned int s)
Sets the number of systems for this DofObject.
~DofObject()=default
Destructor.
bool operator()(const DofObject *a, const DofObject *b) const
const DofObject * get_old_dof_object() const
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.
unsigned int start_idx(const unsigned int s) const
The starting index for system s.
unsigned int packed_indexing_size() const
If we pack our indices into an buffer for communications, how many ints do we need?
std::unique_ptr< DofObject > old_dof_object
This object on the last mesh.
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...
void invalidate_dofs(const unsigned int sys_num=libMesh::invalid_uint)
Sets all degree of freedom numbers to invalid_id.
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...
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...
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
void add_extra_integers(const unsigned int n_integers)
Assigns a set of extra integers to this DofObject.
std::pair< unsigned int, unsigned int > var_to_vg_and_offset(const unsigned int s, const unsigned int var) const
unsigned int n_extra_integers() const
Returns how many extra integers are associated to the DofObject.
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...
void debug_buffer() const
Print our buffer for debugging.
unsigned int n_comp_group(const unsigned int s, const unsigned int vg) const
processor_id_type processor_id() const
processor_id_type _processor_id
The processor_id of the DofObject.
static const index_t ncv_magic_exp
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...
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...
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...