21 #include "libmesh/dof_object.h"
37 #ifdef LIBMESH_ENABLE_UNIQUE_ID
38 _unique_id (dof_obj._unique_id),
42 _idx_buf (dof_obj._idx_buf)
55 for (
auto s : make_range(this->
n_systems()))
57 libmesh_assert_equal_to (this->
n_vars(s), dof_obj.
n_vars(s));
61 libmesh_assert_equal_to (this->
n_vars(s,vg), dof_obj.
n_vars(s,vg));
63 for (
auto v : make_range(this->
n_vars(s)))
65 libmesh_assert_equal_to (this->
n_comp(s,v), dof_obj.
n_comp(s,v));
67 for (
auto c : make_range(this->
n_comp(s,v)))
82 #ifdef LIBMESH_ENABLE_AMR
88 #ifdef LIBMESH_ENABLE_UNIQUE_ID
100 for (
auto s : make_range(this->
n_systems()))
102 libmesh_assert_equal_to (this->
n_vars(s), dof_obj.
n_vars(s));
106 libmesh_assert_equal_to (this->
n_vars(s,vg), dof_obj.
n_vars(s,vg));
108 for (
auto v : make_range(this->
n_vars(s)))
110 libmesh_assert_equal_to (this->
n_comp(s,v), dof_obj.
n_comp(s,v));
112 for (
auto c : make_range(this->
n_comp(s,v)))
126 #ifdef LIBMESH_ENABLE_AMR
152 const unsigned int old_ns = this->
n_systems();
161 static_cast<dof_id_type>(-
static_cast<std::ptrdiff_t
>(header_size))
167 cast_int<unsigned int>(
_idx_buf[old_ns]) :
169 libmesh_assert_less(start_idx_ints,
_idx_buf.size());
172 new_buf.begin()+header_size);
174 std::fill(new_buf.begin()+1, new_buf.begin()+ns+1, ns+1);
184 libmesh_assert_equal_to (ns, this->
n_systems());
185 for (
auto s : make_range(this->
n_systems()))
187 libmesh_assert_equal_to (this->
n_vars(s), 0);
205 const unsigned int ns_orig = this->
n_systems();
207 DofObject::index_buffer_t::iterator it =
_idx_buf.begin() + ns_orig;
221 for (
unsigned int i=1; i<ns_orig+2; i++)
223 libmesh_assert_less(i,
_idx_buf.size());
233 for (
unsigned int i=0; i<ns_orig+1; i++)
235 libmesh_assert_less(i,
_idx_buf.size());
240 libmesh_assert_equal_to (this->
n_systems(), (ns_orig+1));
241 libmesh_assert_equal_to (this->
n_vars(ns_orig), 0);
242 libmesh_assert_equal_to (this->
n_var_groups(ns_orig), 0);
248 const std::vector<unsigned int> & nvpg)
250 const unsigned int n_sys = this->
n_systems();
252 libmesh_assert_less (s, n_sys);
255 const unsigned int nvg = cast_int<unsigned int>(nvpg.size());
267 for (
unsigned int vg=0; vg<nvg; vg++)
270 libmesh_assert_equal_to (this->
n_vars(s,vg), nvpg[vg]);
283 old_system_sizes.reserve(n_sys);
284 old_extra_integers.reserve(nei);
286 for (
unsigned int s_ctr=0; s_ctr<n_sys; s_ctr++)
287 old_system_sizes.push_back(this->n_var_groups(s_ctr));
289 for (
unsigned int ei=0; ei != nei; ++ei)
290 old_extra_integers.push_back(this->get_extra_integer(ei));
298 DofObject::index_buffer_t::iterator
303 std::advance(end, this->
end_idx(s));
306 for (
unsigned int ctr=(s+1); ctr<n_sys; ctr++)
318 for (
auto s_ctr : make_range(this->
n_systems()))
320 libmesh_assert_equal_to (this->
n_var_groups(s_ctr), old_system_sizes[s_ctr]);
324 for (
unsigned int ei=0; ei != nei; ++ei)
335 for (
unsigned int vg=0; vg<nvg; vg++)
337 var_idxs[2*vg ] =
ncv_magic*nvpg[vg] + 0;
341 DofObject::index_buffer_t::iterator it =
_idx_buf.begin();
342 std::advance(it, this->
end_idx(s));
343 _idx_buf.insert(it, var_idxs.begin(), var_idxs.end());
345 for (
unsigned int ctr=(s+1); ctr<n_sys; ctr++)
359 libmesh_assert_equal_to (this->
n_var_groups(s), nvpg.size());
363 libmesh_assert_equal_to (this->
n_vars(s,vg), nvpg[vg]);
367 for (
auto v : make_range(this->
n_vars(s)))
368 libmesh_assert_equal_to (this->
n_comp(s,v), 0);
371 for (
auto s_ctr : make_range(this->
n_systems()))
373 libmesh_assert_equal_to (this->
n_var_groups(s_ctr), old_system_sizes[s_ctr]);
378 for (
unsigned int ei=0; ei != nei; ++ei)
386 const unsigned int var,
387 const unsigned int ncomp)
389 libmesh_assert_less (s, this->
n_systems());
390 libmesh_assert_less (var, this->
n_vars(s));
398 const unsigned int vg,
399 const unsigned int ncomp)
401 libmesh_assert_less (s, this->
n_systems());
411 libmesh_error_msg(
"ERROR: ncomp must be less than DofObject::ncv_magic!\n" \
414 <<
", ncv_magic = " \
416 <<
"\nrecompile and try again!");
422 n_vars_group = this->
n_vars(s,vg),
423 base_offset = start_idx_sys + 2*vg;
425 libmesh_assert_less ((base_offset + 1),
_idx_buf.size());
449 libmesh_assert_equal_to (ncomp, this->
n_comp_group(s,vg));
455 const unsigned int var,
456 const unsigned int comp,
459 libmesh_assert_less (s, this->
n_systems());
460 libmesh_assert_less (var, this->
n_vars(s));
461 libmesh_assert_less (comp, this->
n_comp(s,var));
471 libmesh_assert_less ((start_idx_sys + 2*vg + 1),
_idx_buf.size());
478 (dn == base_idx + vig*ncg + comp));
484 libmesh_assert_equal_to (this->
dof_number(s, var, comp), dn);
510 if (n_integers != old_n_integers)
525 DofObject::index_buffer_t::iterator it =
_idx_buf.begin() + hdr;
530 for (
int i=1; i<hdr; i++)
543 const std::vector<dof_id_type> & default_values)
545 libmesh_assert_equal_to(n_integers, default_values.size());
549 if (n_integers > n_old_integers)
551 const unsigned int n_more_integers = n_integers - n_old_integers;
552 std::copy(default_values.begin()+n_old_integers,
553 default_values.end(),
563 cast_int<unsigned int> (
564 #ifdef LIBMESH_ENABLE_AMR
565 ((
old_dof_object ==
nullptr) ? 0 : old_dof_object->packed_indexing_size()) + 2 +
577 #ifdef LIBMESH_ENABLE_AMR
578 const bool has_old_dof_object = cast_int<bool>(*begin++);
580 static const int dof_header_size = 2;
582 static const bool has_old_dof_object =
false;
583 static const int dof_header_size = 1;
588 return cast_int<unsigned int>
589 (dof_header_size + this_indexing_size +
590 (has_old_dof_object ?
599 #ifdef LIBMESH_ENABLE_AMR
601 const bool has_old_dof_object = cast_int<bool>(*begin++);
606 std::copy(begin, begin+size, back_inserter(
_idx_buf));
611 cast_int<dof_id_signed_type>(
_idx_buf.size())));
616 const unsigned int ns = hdr >= 0 ? hdr : (-hdr-1);
617 for (
unsigned int i=1; i < ns; ++i)
619 if (hdr > 0 || i > 1)
622 libmesh_assert_greater_equal (
_idx_buf[i], ns);
626 if (hdr < 0 && ns > 0)
631 #ifdef LIBMESH_ENABLE_AMR
632 if (has_old_dof_object)
644 #ifdef LIBMESH_ENABLE_AMR
652 #ifdef LIBMESH_ENABLE_AMR
674 for (
auto s : make_range(this->
n_systems()))
677 for (
auto var : make_range(this->
n_vars(s)))
680 for (
auto comp : make_range(this->
n_comp(s,var)))
unsigned int n_comp_group(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.
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.
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 ...
unsigned int n_vars(const unsigned int s, const unsigned int vg) const
bool has_extra_integers() const
Returns whether extra integers are associated to the DofObject.
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
dof_id_type _id
The id of the 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...
void print_dof_info() const
Print out info for debugging.
uint8_t processor_id_type
unsigned int end_idx(const unsigned int s) const
The ending index for system s.
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.
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的绝对值。
void add_system()
Adds an additional system to the DofObject.
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...
unsigned int n_extra_integers() const
Returns how many extra integers are associated to the DofObject.
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 n_var_groups(const unsigned int s) const
processor_id_type _processor_id
The local processor id.
void clear_old_dof_object()
Sets the old_dof_object to nullptr.
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
int8_t dof_id_signed_type
unsigned int start_idx(const unsigned int s) const
The starting index for system s.
DofObject * get_old_dof_object()
Pointer accessor for previously public old_dof_object.
This class implements reference counting.
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...
unsigned int packed_indexing_size() const
If we pack our indices into an buffer for communications, how many ints do we need?
void set_n_systems(const unsigned int s)
Sets the number of systems for this DofObject.
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...
unsigned int start_idx_ints() const
The starting index for an extra_integers pseudosystem.
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.
std::unique_ptr< 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...
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.
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...
unsigned int n_comp(const unsigned int s, const unsigned int var) const
unsigned int n_systems() const
void debug_buffer() const
Print our buffer for debugging.
processor_id_type _processor_id
The processor_id of the DofObject.
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...