Go to the documentation of this file.
   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" 
   55 #ifdef LIBMESH_IS_UNIT_TESTING 
   75 #ifdef LIBMESH_ENABLE_AMR 
  129   unsigned int n_dofs (
const unsigned int s,
 
  130                        const unsigned int var =
 
  157   { this->
set_id() = dofid; }
 
  240   template <
typename T>
 
  249   template <
typename T>
 
  268   unsigned int n_vars(
const unsigned int s,
 
  269                       const unsigned int vg) 
const;
 
  275   unsigned int n_vars(
const unsigned int s) 
const;
 
  285                             const std::vector<unsigned int> & nvpg);
 
  296   unsigned int n_comp(
const unsigned int s,
 
  297                       const unsigned int var) 
const;
 
  309                             const unsigned int vg) 
const;
 
  316                   const unsigned int var,
 
  317                   const unsigned int ncomp);
 
  324                         const unsigned int vg,
 
  325                         const unsigned int ncomp);
 
  336                          const unsigned int var,
 
  337                          const unsigned int comp) 
const;
 
  348                          const unsigned int vg,
 
  349                          const unsigned int vig,
 
  350                          const unsigned int comp,
 
  351                          const unsigned int n_comp) 
const;
 
  358   std::pair<unsigned int, unsigned int>
 
  360                        const unsigned int var) 
const;
 
  367                       const unsigned int var,
 
  368                       const unsigned int comp,
 
  383                        const unsigned int vg,
 
  392                           const unsigned int vg) 
const;
 
  445   (std::vector<largest_id_type>::const_iterator begin);
 
  452   void unpack_indexing(std::vector<largest_id_type>::const_iterator begin);
 
  459   void pack_indexing(std::back_insert_iterator<std::vector<largest_id_type>> target) 
const;
 
  474 #ifndef LIBMESH_ENABLE_DEPRECATED 
  495   unsigned int var_to_vg (
const unsigned int s,
 
  496                           const unsigned int var) 
const;
 
  503                                      const unsigned int vg,
 
  504                                      const unsigned int var) 
const;
 
  509 #ifdef LIBMESH_ENABLE_UNIQUE_ID 
  630   unsigned int start_idx(
const unsigned int s) 
const;
 
  635   unsigned int end_idx(
const unsigned int s) 
const;
 
  648 #ifdef LIBMESH_IS_UNIT_TESTING 
  661 #ifdef LIBMESH_ENABLE_AMR
 
  662   old_dof_object(nullptr),
 
  664 #ifdef LIBMESH_ENABLE_UNIQUE_ID
 
  665   _unique_id (invalid_unique_id),
 
  681 #ifdef LIBMESH_ENABLE_AMR 
  692   const unsigned int n_sys = this->
n_systems();
 
  694   if (sys_num >= n_sys)
 
  746                                 const unsigned int var)
 const 
  748   libmesh_assert_less (s, this->
n_systems());
 
  750   unsigned int num = 0;
 
  759     num = this->
n_comp(s,var);
 
  786 #ifdef LIBMESH_ENABLE_UNIQUE_ID 
  799 #ifdef LIBMESH_ENABLE_UNIQUE_ID 
  802   libmesh_not_implemented();
 
  819 #ifdef LIBMESH_ENABLE_UNIQUE_ID 
  865   return hdr >= 0 ? hdr : (-hdr-1);
 
  883   libmesh_assert_less (s, this->
n_systems());
 
  892                                const unsigned int vg)
 const 
  894   libmesh_assert_less (s,  this->
n_systems());
 
  897   const unsigned int start_idx_sys = this->
start_idx(s);
 
  899   libmesh_assert_less ((start_idx_sys + 2*vg), 
_idx_buf.size());
 
  901   return (cast_int<unsigned int>
 
  910   libmesh_assert_less (s, this->
n_systems());
 
  916   for (
unsigned int vg=0; vg<nvg; vg++)
 
  917     val += this->
n_vars(s,vg);
 
  927                                const unsigned int var)
 const 
  929   libmesh_assert_less (s,   this->
n_systems());
 
  930   libmesh_assert_less (var, this->
n_vars(s));
 
  940                                      const unsigned int vg)
 const 
  942   libmesh_assert_less (s,  this->
n_systems());
 
  948   libmesh_assert_less ((start_idx_sys + 2*vg), 
_idx_buf.size());
 
  957                                   const unsigned int var,
 
  958                                   const unsigned int comp)
 const 
  960   libmesh_assert_less (s,    this->
n_systems());
 
  961   libmesh_assert_less (var,  this->
n_vars(s));
 
  962   libmesh_assert_less (comp, this->
n_comp(s,var));
 
  964   const std::pair<unsigned int, unsigned int>
 
  970   return this->
dof_number(s, vg_vig.first, vg_vig.second,
 
  978                                   const unsigned int vg,
 
  979                                   const unsigned int vig,
 
  980                                   const unsigned int comp,
 
  981                                   const unsigned int n_comp)
 const 
  983   libmesh_assert_less (s,   this->
n_systems());
 
  985   libmesh_assert_less (vig, this->
n_vars(s,vg));
 
  990   libmesh_assert_less ((start_idx_sys + 2*vg + 1), 
_idx_buf.size());
 
  993     base_idx = 
_idx_buf[start_idx_sys + 2*vg + 1];
 
 1003     return cast_int<dof_id_type>(base_idx + vig*
n_comp + comp);
 
 1018   libmesh_assert_less(start_idx_i+index, 
_idx_buf.size());
 
 1033   libmesh_assert_less(start_idx_i+index, 
_idx_buf.size());
 
 1034   return _idx_buf[start_idx_i+index];
 
 1039 template <
typename T>
 
 1046   const unsigned int n_more_integers = (
sizeof(T)-1)/
sizeof(
dof_id_type);
 
 1053   libmesh_assert_less(start_idx_i+index+n_more_integers, 
_idx_buf.size());
 
 1054   std::memcpy(&
_idx_buf[start_idx_i+index], &
value, 
sizeof(T));
 
 1059 template <
typename T>
 
 1065   const unsigned int n_more_integers = (
sizeof(T)-1)/
sizeof(
dof_id_type);
 
 1072   libmesh_assert_less(start_idx_i+index+n_more_integers, 
_idx_buf.size());
 
 1074   std::memcpy(&returnval, &
_idx_buf[start_idx_i+index], 
sizeof(T));
 
 1093   return _idx_buf.size() - start_idx_i;
 
 1111 std::pair<unsigned int, unsigned int>
 
 1113                                 const unsigned int var)
 const 
 1115   std::pair<unsigned int, unsigned int> returnval(0,0);
 
 1117   unsigned int & vg = returnval.first;
 
 1118   unsigned int & offset = returnval.second;
 
 1120   unsigned int vg_start = 0;
 
 1125       const unsigned int vg_end = vg_start + this->
n_vars(s,vg);
 
 1128           offset = var - vg_start;
 
 1149       libmesh_assert_less (sys, this->
n_systems());
 
 1163   libmesh_assert_less (s, this->
n_systems());
 
 1164   libmesh_assert_less (s, 
_idx_buf.size());
 
 1174   libmesh_assert_less (s, this->
n_systems());
 
 1175   libmesh_assert_less (s, 
_idx_buf.size());
 
 1178     cast_int<unsigned int>(
_idx_buf.size()) :
 
 1179     cast_int<unsigned int>(
_idx_buf[s+1]);
 
 1203   return cast_int<unsigned int>(
_idx_buf.size());
 
 1210                                 const unsigned int vg,
 
 1213   libmesh_assert_less (s,  this->
n_systems());
 
 1219   libmesh_assert_less ((start_idx_sys + 2*vg + 1), 
_idx_buf.size());
 
 1221   _idx_buf[start_idx_sys + 2*vg + 1] = db;
 
 1223   libmesh_assert_equal_to (this->
vg_dof_base(s,vg), db);
 
 1230                                    const unsigned int vg)
 const 
 1232   libmesh_assert_less (s,  this->
n_systems());
 
 1238   libmesh_assert_less ((start_idx_sys + 2*vg + 1), 
_idx_buf.size());
 
 1247   return _idx_buf[start_idx_sys + 2*vg + 1];
 
 1254                                    const unsigned int var)
 const 
 1259   for (
unsigned int vg=0, vg_end=0; vg<nvg; vg++)
 
 1261       vg_end += this->
n_vars(s,vg);
 
 1262       if (var < vg_end) 
return vg;
 
 1265   libmesh_error_msg(
"Error: could not map variable " << var << 
" to variable group.");
 
 1272                                               const unsigned int vg,
 
 1273                                               const unsigned int var)
 const 
 1275   unsigned int accumulated_sum=0;
 
 1277   for (
unsigned int vgc=0; vgc<vg; vgc++)
 
 1278     accumulated_sum += this->
n_vars(s,vgc);
 
 1280   libmesh_assert_less_equal (accumulated_sum, var);
 
 1282   return (var - accumulated_sum);
 
 1289 #endif // #ifndef LIBMESH_DOF_OBJECT_H 
  
unsigned int n_dofs(const unsigned int s, const unsigned int var=libMesh::invalid_uint) const
 
unsigned int end_idx(const unsigned int s) const
The ending index for system s.
 
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value.
 
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...
 
processor_id_type _processor_id
The processor_id of the DofObject.
 
unsigned int n_systems() const
 
processor_id_type _processor_id
The local processor id.
 
DofObject * old_dof_object
This object on the last mesh.
 
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...
 
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 ...
 
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...
 
unsigned int start_idx(const unsigned int s) const
The starting index for system s.
 
DofObject & operator=(const DofObject &dof_obj)
Deep-copying assignment operator.
 
This class implements reference counting.
 
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 valid_processor_id() const
 
The libMesh namespace provides an interface to certain functionality in the library.
 
unsigned int start_idx_ints() const
The starting index for an extra_integers pseudosystem.
 
void add_extra_integers(const unsigned int n_integers)
Assigns a set of extra integers to 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.
 
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.
 
unsigned int n_var_groups(const unsigned int s) const
 
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...
 
unique_id_type & set_unique_id()
 
bool valid_unique_id() const
 
static const index_t ncv_magic_exp
 
processor_id_type processor_id() const
 
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
 
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.
 
unsigned int packed_indexing_size() const
If we pack our indices into an buffer for communications, how many ints do we need?
 
void debug_buffer() const
Print our buffer for debugging.
 
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
 
void set_id(const dof_id_type dofid)
Sets the id for this DofObject.
 
The IntRange templated class is intended to make it easy to loop over integers which are indices of a...
 
static const unique_id_type invalid_unique_id
An invalid unique_id to distinguish an uninitialized 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...
 
unsigned int n_extra_integers() const
Returns how many extra integers are associated to the DofObject.
 
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
 
void clear_old_dof_object()
Sets the old_dof_object to nullptr.
 
unsigned int n_comp(const unsigned int s, const unsigned int var) const
 
void print_dof_info() const
Print out info for debugging.
 
unsigned int end_idx_ints() const
The ending index for an extra_integers pseudosystem.
 
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
 
int8_t dof_id_signed_type
 
void set_old_dof_object()
Sets the old_dof_object to a copy of this.
 
uint8_t processor_id_type
 
std::pair< unsigned int, unsigned int > var_to_vg_and_offset(const unsigned int s, const unsigned int var) const
 
void set_n_systems(const unsigned int s)
Sets the number of systems for this DofObject.
 
bool has_extra_integers() const
Returns whether extra integers are associated to the DofObject.
 
void invalidate()
Invalidates all the indices for this DofObject.
 
unique_id_type unique_id() const
 
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 add_system()
Adds an additional system to the DofObject.
 
unsigned int n_vars(const unsigned int s, const unsigned int vg) const
 
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.
 
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...
 
dof_id_type _id
The id of the 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 clear_dofs()
Clear the DofMap data structures holding degree of freedom data.
 
void set_buffer(const std::vector< dof_id_type > &buf)
 
dof_id_type index_t
DoF index information.
 
void invalidate_processor_id()
Sets the processor id to invalid_processor_id.
 
unsigned int n_comp_group(const unsigned int s, const unsigned int vg) const
 
unique_id_type _unique_id
A globally unique id, guaranteed not to change as the mesh is repartitioned or adapted.
 
void invalidate_dofs(const unsigned int sys_num=libMesh::invalid_uint)
Sets all degree of freedom numbers to invalid_id.
 
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...
 
bool has_dofs(const unsigned int s=libMesh::invalid_uint) const
 
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...
 
std::vector< index_t > index_buffer_t
 
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...
 
void invalidate_id()
Sets the id to invalid_id.
 
unsigned int n_pseudo_systems() const