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 =
193 { this->
set_id() = dofid; }
276 template <
typename T>
285 template <
typename T>
304 unsigned int n_vars(
const unsigned int s,
305 const unsigned int vg)
const;
311 unsigned int n_vars(
const unsigned int s)
const;
321 const std::vector<unsigned int> & nvpg);
332 unsigned int n_comp(
const unsigned int s,
333 const unsigned int var)
const;
345 const unsigned int vg)
const;
352 const unsigned int var,
353 const unsigned int ncomp);
360 const unsigned int vg,
361 const unsigned int ncomp);
372 const unsigned int var,
373 const unsigned int comp)
const;
384 const unsigned int vg,
385 const unsigned int vig,
386 const unsigned int comp,
387 const unsigned int n_comp)
const;
394 std::pair<unsigned int, unsigned int>
396 const unsigned int var)
const;
403 const unsigned int var,
404 const unsigned int comp,
419 const unsigned int vg,
428 const unsigned int vg)
const;
454 const std::vector<dof_id_type> & default_values);
497 (std::vector<largest_id_type>::const_iterator begin);
504 void unpack_indexing(std::vector<largest_id_type>::const_iterator begin);
511 void pack_indexing(std::back_insert_iterator<std::vector<largest_id_type>> target)
const;
541 std::unique_ptr<DofObject>
553 unsigned int var_to_vg (
const unsigned int s,
554 const unsigned int var)
const;
561 const unsigned int vg,
562 const unsigned int var)
const;
567 #ifdef LIBMESH_ENABLE_UNIQUE_ID 688 unsigned int start_idx(
const unsigned int s)
const;
693 unsigned int end_idx(
const unsigned int s)
const;
706 #ifdef LIBMESH_IS_UNIT_TESTING 719 #ifdef LIBMESH_ENABLE_UNIQUE_ID
720 _unique_id (invalid_unique_id),
731 std::unique_ptr<DofObject>
735 ? std::unique_ptr<DofObject>(
new DofObject(*other))
736 : std::unique_ptr<DofObject>(
new DofObject());
744 const unsigned int n_sys = this->
n_systems();
746 if (sys_num >= n_sys)
798 const unsigned int var)
const 800 libmesh_assert_less (s, this->
n_systems());
802 unsigned int num = 0;
811 num = this->
n_comp(s,var);
837 #ifdef LIBMESH_ENABLE_UNIQUE_ID 850 #ifdef LIBMESH_ENABLE_UNIQUE_ID 854 libmesh_not_implemented();
871 #ifdef LIBMESH_ENABLE_UNIQUE_ID 917 return hdr >= 0 ? hdr : (-hdr-1);
927 return std::abs(hdr);
935 libmesh_assert_less (s, this->
n_systems());
944 const unsigned int vg)
const 946 libmesh_assert_less (s, this->
n_systems());
949 const unsigned int start_idx_sys = this->
start_idx(s);
951 libmesh_assert_less ((start_idx_sys + 2*vg),
_idx_buf.size());
953 return (cast_int<unsigned int>
962 libmesh_assert_less (s, this->
n_systems());
968 for (
unsigned int vg=0; vg<nvg; vg++)
969 val += this->
n_vars(s,vg);
979 const unsigned int var)
const 981 libmesh_assert_less (s, this->
n_systems());
982 libmesh_assert_less (var, this->
n_vars(s));
992 const unsigned int vg)
const 994 libmesh_assert_less (s, this->
n_systems());
1000 libmesh_assert_less ((start_idx_sys + 2*vg),
_idx_buf.size());
1009 const unsigned int var,
1010 const unsigned int comp)
const 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));
1016 const std::pair<unsigned int, unsigned int>
1022 return this->
dof_number(s, vg_vig.first, vg_vig.second,
1030 const unsigned int vg,
1031 const unsigned int vig,
1032 const unsigned int comp,
1033 const unsigned int n_comp)
const 1035 libmesh_assert_less (s, this->
n_systems());
1037 libmesh_assert_less (vig, this->
n_vars(s,vg));
1042 libmesh_assert_less ((start_idx_sys + 2*vg + 1),
_idx_buf.size());
1045 base_idx =
_idx_buf[start_idx_sys + 2*vg + 1];
1055 return cast_int<dof_id_type>(base_idx + vig*
n_comp + comp);
1070 libmesh_assert_less(start_idx_i+index,
_idx_buf.size());
1085 libmesh_assert_less(start_idx_i+index,
_idx_buf.size());
1086 return _idx_buf[start_idx_i+index];
1095 #include "libmesh/ignore_warnings.h" 1099 template <
typename T>
1106 const unsigned int n_more_integers = (
sizeof(T)-1)/
sizeof(
dof_id_type);
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));
1119 template <
typename T>
1125 const unsigned int n_more_integers = (
sizeof(T)-1)/
sizeof(
dof_id_type);
1132 libmesh_assert_less(start_idx_i+index+n_more_integers,
_idx_buf.size());
1134 std::memcpy(&returnval, &
_idx_buf[start_idx_i+index],
sizeof(T));
1140 #include "libmesh/restore_warnings.h" 1157 return _idx_buf.size() - start_idx_i;
1175 std::pair<unsigned int, unsigned int>
1177 const unsigned int var)
const 1179 std::pair<unsigned int, unsigned int> returnval(0,0);
1181 unsigned int & vg = returnval.first;
1182 unsigned int & offset = returnval.second;
1184 unsigned int vg_start = 0;
1189 const unsigned int vg_end = vg_start + this->
n_vars(s,vg);
1192 offset = var - vg_start;
1213 libmesh_assert_less (sys, this->
n_systems());
1227 libmesh_assert_less (s, this->
n_systems());
1228 libmesh_assert_less (s,
_idx_buf.size());
1238 libmesh_assert_less (s, this->
n_systems());
1239 libmesh_assert_less (s,
_idx_buf.size());
1242 cast_int<unsigned int>(
_idx_buf.size()) :
1243 cast_int<unsigned int>(
_idx_buf[s+1]);
1267 return cast_int<unsigned int>(
_idx_buf.size());
1274 const unsigned int vg,
1277 libmesh_assert_less (s, this->
n_systems());
1283 libmesh_assert_less ((start_idx_sys + 2*vg + 1),
_idx_buf.size());
1285 _idx_buf[start_idx_sys + 2*vg + 1] = db;
1287 libmesh_assert_equal_to (this->
vg_dof_base(s,vg), db);
1294 const unsigned int vg)
const 1296 libmesh_assert_less (s, this->
n_systems());
1302 libmesh_assert_less ((start_idx_sys + 2*vg + 1),
_idx_buf.size());
1311 return _idx_buf[start_idx_sys + 2*vg + 1];
1318 const unsigned int var)
const 1323 for (
unsigned int vg=0, vg_end=0; vg<nvg; vg++)
1325 vg_end += this->
n_vars(s,vg);
1326 if (var < vg_end)
return vg;
1329 libmesh_error_msg(
"Error: could not map variable " << var <<
" to variable group.");
1336 const unsigned int vg,
1337 const unsigned int var)
const 1339 unsigned int accumulated_sum=0;
1341 for (
unsigned int vgc=0; vgc<vg; vgc++)
1342 accumulated_sum += this->
n_vars(s,vgc);
1344 libmesh_assert_less_equal (accumulated_sum, var);
1346 return (var - accumulated_sum);
1362 return a->
id() <
b->id();
1379 return a->
id() <
b->id();
1386 #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...
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
static constexpr processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
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
static constexpr unique_id_type invalid_unique_id
An invalid unique_id to distinguish an uninitialized DofObject.
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 constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
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.
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_unique_id(unique_id_type new_id)
Sets the unique_id for this DofObject.
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...