libMesh::DofObject Class Reference

#include <dof_object.h>

Inheritance diagram for libMesh::DofObject:

Public Member Functions

void clear_old_dof_object ()
 
void set_old_dof_object ()
 
void clear_dofs ()
 
void invalidate_dofs (const unsigned int sys_num=libMesh::invalid_uint)
 
void invalidate_id ()
 
void invalidate_processor_id ()
 
void invalidate ()
 
unsigned int n_dofs (const unsigned int s, const unsigned int var=libMesh::invalid_uint) const
 
dof_id_type id () const
 
dof_id_typeset_id ()
 
unique_id_type unique_id () const
 
unique_id_typeset_unique_id ()
 
void set_id (const dof_id_type dofid)
 
bool valid_id () const
 
bool valid_unique_id () const
 
processor_id_type processor_id () const
 
processor_id_typeprocessor_id ()
 
void processor_id (const processor_id_type pid)
 
bool valid_processor_id () const
 
unsigned int n_systems () const
 
void set_n_systems (const unsigned int s)
 
void add_system ()
 
unsigned int n_var_groups (const unsigned int s) const
 
unsigned int n_vars (const unsigned int s, const unsigned int vg) const
 
unsigned int n_vars (const unsigned int s) const
 
void set_n_vars_per_group (const unsigned int s, const std::vector< unsigned int > &nvpg)
 
unsigned int n_comp (const unsigned int s, const unsigned int var) const
 
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)
 
void set_n_comp_group (const unsigned int s, const unsigned int vg, const unsigned int ncomp)
 
dof_id_type dof_number (const unsigned int s, const unsigned int var, const unsigned int comp) const
 
void set_dof_number (const unsigned int s, const unsigned int var, const unsigned int comp, const dof_id_type dn)
 
bool has_dofs (const unsigned int s=libMesh::invalid_uint) const
 
void set_vg_dof_base (const unsigned int s, const unsigned int vg, const dof_id_type db)
 
dof_id_type vg_dof_base (const unsigned int s, const unsigned int vg) const
 
unsigned int packed_indexing_size () const
 
void unpack_indexing (std::vector< largest_id_type >::const_iterator begin)
 
void pack_indexing (std::back_insert_iterator< std::vector< largest_id_type > > target) const
 
void debug_buffer () const
 
void set_buffer (const std::vector< dof_id_type > &buf)
 

Static Public Member Functions

static unsigned int unpackable_indexing_size (std::vector< largest_id_type >::const_iterator begin)
 
static std::string get_info ()
 
static void print_info (std::ostream &out=libMesh::out)
 
static unsigned int n_objects ()
 
static void enable_print_counter_info ()
 
static void disable_print_counter_info ()
 

Public Attributes

DofObjectold_dof_object
 

Static Public Attributes

static const dof_id_type invalid_id = static_cast<dof_id_type>(-1)
 
static const unique_id_type invalid_unique_id = static_cast<unique_id_type>(-1)
 
static const processor_id_type invalid_processor_id = static_cast<processor_id_type>(-1)
 

Protected Types

typedef std::map< std::string,
std::pair< unsigned int,
unsigned int > > 
Counts
 

Protected Member Functions

 DofObject ()
 
 ~DofObject ()
 
 DofObject (const DofObject &)
 
DofObjectoperator= (const DofObject &dof_obj)
 
void increment_constructor_count (const std::string &name)
 
void increment_destructor_count (const std::string &name)
 

Static Protected Attributes

static Counts _counts
 
static Threads::atomic
< unsigned int > 
_n_objects
 
static Threads::spin_mutex _mutex
 
static bool _enable_print_counter = true
 

Private Types

typedef dof_id_type index_t
 
typedef std::vector< index_tindex_buffer_t
 

Private Member Functions

unsigned int var_to_vg (const unsigned int s, const unsigned int var) const
 
unsigned int system_var_to_vg_var (const unsigned int s, const unsigned int vg, const unsigned int var) const
 
unsigned int start_idx (const unsigned int s) const
 
unsigned int end_idx (const unsigned int s) const
 

Private Attributes

dof_id_type _id
 
unique_id_type _unique_id
 
processor_id_type _processor_id
 
index_buffer_t _idx_buf
 

Static Private Attributes

static const index_t ncv_magic = 256
 

Detailed Description

The DofObject defines an abstract base class for objects that have degrees of freedom associated with them. Examples of such objects are the Node and Elem classes. This class can not be instantiated, only derived from.

Author
Benjamin S. Kirk
Date
2003, 2011

Definition at line 51 of file dof_object.h.

Member Typedef Documentation

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information. The log is identified by the class name.

Definition at line 113 of file reference_counter.h.

typedef std::vector<index_t> libMesh::DofObject::index_buffer_t
private

Definition at line 464 of file dof_object.h.

DoF index information. This is packed into a contiguous buffer of the following format:

[ns end_0 end_1 ... end_{ns-1} (ncv_0 idx_0 ncv_1 idx_1 ... ncv_nv idx_nv)_0 (ncv_0 idx_0 ncv_1 idx_1 ... ncv_nv idx_nv)_1 ... (ncv_0 idx_0 ncv_1 idx_1 ... ncv_nv idx_nv)_ns ]

where 'end_s' is the index past the end of the variable group storage for system s. Note that we specifically do not store the end for the last system - this always _idx_buf.size().

Specifically, consider the case of 4 systems, with 3, 0, 1, 2 variable groups, respectively. The _idx_buf then looks like:

 [4 10 10 12 () (ncv_0 idx_0 ncv_1 idx_1 ncv_2 idx_2) () (ncv_0 idx_0) (ncv_0 idx_0 ncv_1 idx_1)]
 [0  1  2  3         4     5     6     7     8     9         10    11      12    13    14    15]

The ending index is then given by

 end_s = _idx_buf.size(), s == (ns-1),
       = _idx_buf[s+1]    otherwise.

The starting indices are not specifically stored, but rather inferred as follows:

start_s = _idx_buf[s];

Now, the defining characteristic of the VariableGroup is that it supports an arbitrary number of variables of the same type. At the DofObject level, what that means is that each Variable in the VariableGroup will have the same number of nonzero components, and they can all be indexed from the same base number. We use this information in the ncv_# and idx_# entries as follows:

ncv_# = n_vars*ncv_magic + n_comp for variable group # idx_# = base_offset for variable group #

the DoF index for a particular component c of variable v within that group is then given by

idx_var = idx_# + n_comp*v + c

note there is a subtlety here - "variable v within that group" usually means nothing to the user. This class is either indexed with variable group numbers, or variable numbers counted within the system. So for a system with 2 variable groups, 4 and 8 variables each, the 5th variable in the system is the 1st variable in 2nd variable group. (Now of course 0-base everything... but you get the idea.)

Definition at line 463 of file dof_object.h.

Constructor & Destructor Documentation

libMesh::DofObject::DofObject ( )
inlineprotected

Constructor. Protected so that you can't instantiate one of these except as a part of a Node or Elem.

Definition at line 501 of file dof_object.h.

References invalidate().

Referenced by operator=(), set_old_dof_object(), and unpack_indexing().

501  :
502 #ifdef LIBMESH_ENABLE_AMR
503  old_dof_object(NULL),
504 #endif
505  _id (invalid_id),
506 #ifdef LIBMESH_ENABLE_UNIQUE_ID
508 #endif
510 {
511  this->invalidate();
512 }
libMesh::DofObject::~DofObject ( )
inlineprotected

Destructor. Protected so that you can't destroy one of these except as a part of a Node or Elem.

Definition at line 519 of file dof_object.h.

References clear_dofs(), and clear_old_dof_object().

520 {
521  // Free all memory.
522 #ifdef LIBMESH_ENABLE_AMR
523  this->clear_old_dof_object ();
524 #endif
525  this->clear_dofs ();
526 }
libMesh::DofObject::DofObject ( const DofObject dof_obj)
protected

Copy-constructor.

Definition at line 42 of file dof_object.C.

References dof_number(), n_comp(), n_systems(), n_var_groups(), and n_vars().

42  :
43  ReferenceCountedObject<DofObject>(),
44 #ifdef LIBMESH_ENABLE_AMR
45  old_dof_object (NULL),
46 #endif
47  _id (dof_obj._id),
48 #ifdef LIBMESH_ENABLE_UNIQUE_ID
49  _unique_id (dof_obj._unique_id),
50 #endif
51  _processor_id (dof_obj._processor_id),
52  _idx_buf (dof_obj._idx_buf)
53 {
54 
55  // Check that everything worked
56 #ifdef DEBUG
57 
58  libmesh_assert_equal_to (this->n_systems(), dof_obj.n_systems());
59 
60  for (unsigned int s=0; s<this->n_systems(); s++)
61  {
62  libmesh_assert_equal_to (this->n_vars(s), dof_obj.n_vars(s));
63  libmesh_assert_equal_to (this->n_var_groups(s), dof_obj.n_var_groups(s));
64 
65  for (unsigned int vg=0; vg<this->n_var_groups(s); vg++)
66  libmesh_assert_equal_to (this->n_vars(s,vg), dof_obj.n_vars(s,vg));
67 
68  for (unsigned int v=0; v<this->n_vars(s); v++)
69  {
70  libmesh_assert_equal_to (this->n_comp(s,v), dof_obj.n_comp(s,v));
71 
72  for (unsigned int c=0; c<this->n_comp(s,v); c++)
73  libmesh_assert_equal_to (this->dof_number(s,v,c), dof_obj.dof_number(s,v,c));
74  }
75  }
76 
77 #endif
78 }

Member Function Documentation

void libMesh::DofObject::add_system ( )

Adds an additional system to the DofObject

Definition at line 189 of file dof_object.C.

References _idx_buf, n_systems(), n_var_groups(), n_vars(), and set_n_systems().

190 {
191  // quick return?
192  if (this->n_systems() == 0)
193  {
194  this->set_n_systems(1);
195  return;
196  }
197 
198  DofObject::index_buffer_t::iterator it = _idx_buf.begin();
199 
200  std::advance(it, this->n_systems());
201 
202  // this inserts the current vector size at the position for the new system - creating the
203  // entry we need for the new system indicating there are 0 variables.
204  _idx_buf.insert(it, _idx_buf.size());
205 
206  // cache this value before we screw it up!
207  const unsigned int ns_orig = this->n_systems();
208 
209  // incriment the number of systems and the offsets for each of
210  // the systems including the new one we just added.
211  for (unsigned int i=0; i<ns_orig+1; i++)
212  _idx_buf[i]++;
213 
214  libmesh_assert_equal_to (this->n_systems(), (ns_orig+1));
215  libmesh_assert_equal_to (this->n_vars(ns_orig), 0);
216  libmesh_assert_equal_to (this->n_var_groups(ns_orig), 0);
217 }
void libMesh::DofObject::clear_dofs ( )
inline

Clear the DofMap data structures and return to a pristine state.

Definition at line 577 of file dof_object.h.

References _idx_buf, libMesh::libmesh_assert(), and n_systems().

Referenced by set_n_systems(), and ~DofObject().

578 {
579  // vector swap trick to force deallocation
580  index_buffer_t().swap(_idx_buf);
581 
582  libmesh_assert_equal_to (this->n_systems(), 0);
583  libmesh_assert (_idx_buf.empty());
584 }
void libMesh::DofObject::clear_old_dof_object ( )

Sets the old_dof_object to NULL

Definition at line 131 of file dof_object.C.

References old_dof_object.

Referenced by operator=(), set_old_dof_object(), unpack_indexing(), and ~DofObject().

132 {
133  // If we have been called before...
134  // prevent a memory leak
135  if (old_dof_object != NULL)
136  {
137  delete this->old_dof_object;
138  this->old_dof_object = NULL;
139  }
140 }
void libMesh::DofObject::debug_buffer ( ) const

Print our buffer for debugging.

Definition at line 543 of file dof_object.C.

References _idx_buf, and libMesh::out.

544 {
545  libMesh::out << " [ ";
546  for (unsigned int i=0; i<_idx_buf.size(); i++)
547  libMesh::out << _idx_buf[i] << " ";
548  libMesh::out << "]\n";
549 }
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 106 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

107 {
108  _enable_print_counter = false;
109  return;
110 }
dof_id_type libMesh::DofObject::dof_number ( const unsigned int  s,
const unsigned int  var,
const unsigned int  comp 
) const
inline
Returns
the global degree of freedom number for variable var, component comp for system s associated with this DofObject

When partitioning and DoF numbering have been performed by libMesh, every current DoF on this DofObject will belong to its processor.

Definition at line 789 of file dof_object.h.

References _idx_buf, invalid_id, n_comp(), n_comp_group(), n_systems(), n_vars(), start_idx(), system_var_to_vg_var(), and var_to_vg().

Referenced by libMesh::DofMap::add_neighbors_to_send_list(), libMesh::FEGenericBase< T >::compute_periodic_constraints(), libMesh::DofMap::constrain_p_dofs(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::dof_indices(), DofObject(), libMesh::Node::get_info(), libMesh::Elem::get_info(), libMesh::DofMap::old_dof_indices(), operator=(), libMesh::HPCoarsenTest::select_refinement(), set_dof_number(), libMesh::DofMap::set_nonlocal_dof_objects(), and libMesh::System::zero_variable().

792 {
793  libmesh_assert_less (s, this->n_systems());
794  libmesh_assert_less (var, this->n_vars(s));
795  libmesh_assert_less (comp, this->n_comp(s,var));
796 
797  const unsigned int
798  vg = this->var_to_vg(s,var),
799  start_idx_sys = this->start_idx(s);
800 
801  libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
802 
803  const dof_id_type
804  base_idx = _idx_buf[start_idx_sys + 2*vg + 1];
805 
806  // if the first component is invalid, they
807  // are all invalid
808  if (base_idx == invalid_id)
809  return invalid_id;
810 
811  // otherwise the index is the first component
812  // index augemented by the component number
813  else
814  {
815  const unsigned int
816  ncg = this->n_comp_group(s,vg),
817  vig = this->system_var_to_vg_var(s,vg,var);
818 
819  // std::cout << "base_idx, var, vg, vig, ncg, comp="
820  // << base_idx << " "
821  // << var << " "
822  // << vg << " "
823  // << vig << " "
824  // << ncg << " "
825  // << comp << '\n';
826 
827  return libmesh_cast_int<dof_id_type>(base_idx + vig*ncg + comp);
828  }
829 }
void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

Definition at line 100 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

101 {
102  _enable_print_counter = true;
103  return;
104 }
unsigned int libMesh::DofObject::end_idx ( const unsigned int  s) const
inlineprivate

The ending index for system s.

Definition at line 868 of file dof_object.h.

References _idx_buf, and n_systems().

Referenced by n_var_groups(), and set_n_vars_per_group().

869 {
870  libmesh_assert_less (s, this->n_systems());
871  libmesh_assert_less (s, _idx_buf.size());
872 
873  return ((s+1) == this->n_systems()) ?
874  libmesh_cast_int<unsigned int>(_idx_buf.size()) :
875  libmesh_cast_int<unsigned int>(_idx_buf[s+1]);
876 }
std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().

Referenced by libMesh::ReferenceCounter::print_info().

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (Counts::iterator it = _counts.begin();
59  it != _counts.end(); ++it)
60  {
61  const std::string name(it->first);
62  const unsigned int creations = it->second.first;
63  const unsigned int destructions = it->second.second;
64 
65  oss << "| " << name << " reference count information:\n"
66  << "| Creations: " << creations << '\n'
67  << "| Destructions: " << destructions << '\n';
68  }
69 
70  oss << " ---------------------------------------------------------------------------- \n";
71 
72  return oss.str();
73 
74 #else
75 
76  return "";
77 
78 #endif
79 }
bool libMesh::DofObject::has_dofs ( const unsigned int  s = libMesh::invalid_uint) const
inline
Returns
true if any system has variables which have been assigned, false otherwise

Definition at line 834 of file dof_object.h.

References libMesh::invalid_uint, n_systems(), and n_vars().

Referenced by libMesh::MeshTools::libmesh_assert_old_dof_objects(), libMesh::DofMap::reinit(), and libMesh::Parallel::unpack().

835 {
836  if (sys == libMesh::invalid_uint)
837  {
838  for (unsigned int s=0; s<this->n_systems(); s++)
839  if (this->n_vars(s))
840  return true;
841  }
842 
843  else
844  {
845  libmesh_assert_less (sys, this->n_systems());
846 
847  if (this->n_vars(sys))
848  return true;
849  }
850 
851  return false;
852 }
dof_id_type libMesh::DofObject::id ( ) const
inline
Returns
the id for this DofObject

Definition at line 611 of file dof_object.h.

References _id, libMesh::libmesh_assert(), and valid_id().

Referenced by libMesh::MetisPartitioner::_do_partition(), libMesh::SFCPartitioner::_do_partition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::SerialMesh::add_elem(), libMesh::ParallelMesh::add_elem(), libMesh::SerialMesh::add_node(), libMesh::ParallelMesh::add_node(), libMesh::ParallelMesh::add_point(), libMesh::UnstructuredMesh::all_first_order(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::MeshData::assign(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::MeshTools::Generation::build_delaunay_square(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::ParmetisPartitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::VTKIO::cells_to_vtk(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::FEGenericBase< T >::compute_periodic_constraints(), libMesh::FEMap::compute_single_point_map(), libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::SerialMesh::delete_elem(), libMesh::ParallelMesh::delete_elem(), libMesh::SerialMesh::delete_node(), libMesh::ParallelMesh::delete_node(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::MeshData::elem_to_foreign_id(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::MeshTools::find_nodal_neighbors(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_error_tolerance(), libMesh::MeshRefinement::flag_elements_by_mean_stddev(), libMesh::MeshTools::Modification::flatten(), libMesh::for(), libMesh::Node::get_info(), libMesh::Elem::get_info(), libMesh::DofMap::get_local_constraints(), libMesh::EquationSystems::get_solution(), libMesh::LaplaceMeshSmoother::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_discontinuous(), libMesh::TreeNode< N >::insert(), libMesh::SerialMesh::insert_elem(), libMesh::ParallelMesh::insert_elem(), libMesh::SerialMesh::insert_node(), libMesh::FE< Dim, T >::inverse_map(), libMesh::MeshTools::libmesh_assert_valid_amr_elem_ids(), libMesh::MeshTools::libmesh_assert_valid_elem_ids(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::Elem::node(), libMesh::MeshData::node_to_foreign_id(), libMesh::VTKIO::nodes_to_vtk(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::BoundaryInfo::operator=(), libMesh::Parallel::pack(), libMesh::Node::PackedNode::pack(), libMesh::Elem::PackedElem::pack(), libMesh::ErrorVector::plot_error(), libMesh::ParallelMesh::query_elem(), libMesh::ParallelMesh::query_node_ptr(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::AbaqusIO::read_elements(), libMesh::ParallelMesh::renumber_elem(), libMesh::ParallelMesh::renumber_node(), libMesh::ParallelMesh::renumber_nodes_and_elements(), libMesh::DofMap::scatter_constraints(), libMesh::HPCoarsenTest::select_refinement(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::FE< Dim, T >::shape(), libMesh::FE< Dim, T >::shape_deriv(), libMesh::FE< Dim, T >::shape_second_deriv(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshTools::Modification::smooth(), libMesh::SerialMesh::stitching_helper(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_dofobject_data_by_id(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Elem::topological_neighbor(), libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), libMesh::Node::PackedNode::unpack(), libMesh::Parallel::unpack(), libMesh::Elem::PackedElem::unpack(), libMesh::GMVIO::write_ascii_new_impl(), libMesh::GMVIO::write_ascii_old_impl(), libMesh::CheckpointIO::write_connectivity(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elements_discontinuous(), libMesh::GmshIO::write_mesh(), libMesh::LegacyXdrIO::write_mesh(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::CheckpointIO::write_nodes(), and libMesh::XdrIO::write_serialized_connectivity().

612 {
613  libmesh_assert (this->valid_id());
614  return _id;
615 }
void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectedinherited

Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.

Definition at line 163 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

164 {
165  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
166  std::pair<unsigned int, unsigned int>& p = _counts[name];
167 
168  p.first++;
169 }
void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectedinherited

Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.

Definition at line 176 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

177 {
178  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
179  std::pair<unsigned int, unsigned int>& p = _counts[name];
180 
181  p.second++;
182 }
void libMesh::DofObject::invalidate ( )
inline

Invalidates all the indices for this DofObject

Definition at line 567 of file dof_object.h.

References invalidate_dofs(), invalidate_id(), and invalidate_processor_id().

Referenced by DofObject().

568 {
569  this->invalidate_dofs ();
570  this->invalidate_id ();
571  this->invalidate_processor_id ();
572 }
void libMesh::DofObject::invalidate_dofs ( const unsigned int  sys_num = libMesh::invalid_uint)
inline

Sets all degree of freedom numbers to invalid_id

Definition at line 531 of file dof_object.h.

References invalid_id, n_comp_group(), n_systems(), n_var_groups(), and set_vg_dof_base().

Referenced by invalidate().

532 {
533  // If the user does not specify the system number...
534  if (sys_num >= this->n_systems())
535  {
536  for (unsigned int s=0; s<this->n_systems(); s++)
537  for (unsigned int vg=0; vg<this->n_var_groups(s); vg++)
538  if (this->n_comp_group(s,vg))
539  this->set_vg_dof_base(s,vg,invalid_id);
540  }
541  // ...otherwise invalidate the dofs for all systems
542  else
543  for (unsigned int vg=0; vg<this->n_var_groups(sys_num); vg++)
544  if (this->n_comp_group(sys_num,vg))
545  this->set_vg_dof_base(sys_num,vg,invalid_id);
546 }
void libMesh::DofObject::invalidate_id ( )
inline

Sets the id to invalid_id

Definition at line 551 of file dof_object.h.

References invalid_id, and set_id().

Referenced by invalidate().

552 {
553  this->set_id (invalid_id);
554 }
void libMesh::DofObject::invalidate_processor_id ( )
inline
unsigned int libMesh::DofObject::n_comp ( const unsigned int  s,
const unsigned int  var 
) const
inline
Returns
the number of components for variable var of system s associated with this DofObject. For example, the HIERARCHIC shape functions may have multiple DoFs associated with one node. Another example is the MONOMIALs, where only the elements hold the DoFs. For the different spatial directions, and orders, see FE.

Definition at line 759 of file dof_object.h.

References n_comp_group(), n_systems(), n_vars(), and var_to_vg().

Referenced by libMesh::DofMap::add_neighbors_to_send_list(), libMesh::FEGenericBase< T >::compute_periodic_constraints(), libMesh::DofMap::constrain_p_dofs(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::dof_indices(), dof_number(), DofObject(), libMesh::Node::get_info(), libMesh::Elem::get_info(), n_dofs(), libMesh::DofMap::old_dof_indices(), operator=(), set_dof_number(), set_n_vars_per_group(), libMesh::DofMap::set_nonlocal_dof_objects(), and libMesh::System::zero_variable().

761 {
762  libmesh_assert_less (s, this->n_systems());
763  libmesh_assert_less (var, this->n_vars(s));
764 
765  return this->n_comp_group(s,this->var_to_vg(s,var));
766 }
unsigned int libMesh::DofObject::n_comp_group ( const unsigned int  s,
const unsigned int  vg 
) const
inline
Returns
the number of components for VariableGroup vg of system s associated with this DofObject. For example, the HIERARCHIC shape functions may have multiple DoFs associated with one node. Another example is the MONOMIALs, where only the elements hold the DoFs. For the different spatial directions, and orders, see FE.

Definition at line 772 of file dof_object.h.

References _idx_buf, n_systems(), n_var_groups(), ncv_magic, and start_idx().

Referenced by libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), dof_number(), invalidate_dofs(), n_comp(), libMesh::DofMap::reinit(), set_dof_number(), set_n_comp_group(), set_n_vars_per_group(), and libMesh::DofMap::set_nonlocal_dof_objects().

774 {
775  libmesh_assert_less (s, this->n_systems());
776  libmesh_assert_less (vg, this->n_var_groups(s));
777 
778  const unsigned int
779  start_idx_sys = this->start_idx(s);
780 
781  libmesh_assert_less ((start_idx_sys + 2*vg), _idx_buf.size());
782 
783  return (_idx_buf[start_idx_sys + 2*vg] % ncv_magic);
784 }
unsigned int libMesh::DofObject::n_dofs ( const unsigned int  s,
const unsigned int  var = libMesh::invalid_uint 
) const
inline
Returns
the number of degrees of freedom associated with system s for this object. Optionally only counts degrees of freedom for variable number var

Definition at line 589 of file dof_object.h.

References libMesh::invalid_uint, n_comp(), n_systems(), and n_vars().

Referenced by libMesh::EquationSystems::build_solution_vector().

591 {
592  libmesh_assert_less (s, this->n_systems());
593 
594  unsigned int num = 0;
595 
596  // Count all variables
597  if (var == libMesh::invalid_uint)
598  for (unsigned int v=0; v<this->n_vars(s); v++)
599  num += this->n_comp(s,v);
600 
601  // Only count specified variable
602  else
603  num = this->n_comp(s,var);
604 
605  return num;
606 }
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 79 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

80  { return _n_objects; }
unsigned int libMesh::DofObject::n_var_groups ( const unsigned int  s) const
inline
Returns
the number of VariableGroup variable groups associated with system s for this DofObject

Definition at line 714 of file dof_object.h.

References end_idx(), n_systems(), and start_idx().

Referenced by add_system(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), DofObject(), invalidate_dofs(), n_comp_group(), n_vars(), operator=(), set_n_comp_group(), set_n_systems(), set_n_vars_per_group(), libMesh::DofMap::set_nonlocal_dof_objects(), set_vg_dof_base(), var_to_vg(), and vg_dof_base().

715 {
716  libmesh_assert_less (s, this->n_systems());
717 
718  return (this->end_idx(s) - this->start_idx(s)) / 2;
719 }
unsigned int libMesh::DofObject::n_vars ( const unsigned int  s,
const unsigned int  vg 
) const
inline
Returns
the number of Variable variables associated with VariableGroup vg in system s for this DofObject

Definition at line 724 of file dof_object.h.

References _idx_buf, n_systems(), n_var_groups(), ncv_magic, and start_idx().

Referenced by libMesh::DofMap::add_neighbors_to_send_list(), add_system(), libMesh::DofMap::distribute_dofs(), dof_number(), DofObject(), libMesh::Node::get_info(), libMesh::Elem::get_info(), has_dofs(), n_comp(), n_dofs(), n_vars(), operator=(), set_dof_number(), set_n_comp(), set_n_comp_group(), set_n_systems(), set_n_vars_per_group(), libMesh::DofMap::set_nonlocal_dof_objects(), system_var_to_vg_var(), and var_to_vg().

726 {
727  libmesh_assert_less (s, this->n_systems());
728  libmesh_assert_less (vg, this->n_var_groups(s));
729 
730  const unsigned int start_idx_sys = this->start_idx(s);
731 
732  libmesh_assert_less ((start_idx_sys + 2*vg), _idx_buf.size());
733 
734  return (libmesh_cast_int<unsigned int>
735  (_idx_buf[start_idx_sys + 2*vg]) / ncv_magic);
736 }
unsigned int libMesh::DofObject::n_vars ( const unsigned int  s) const
inline
Returns
the number of Variable variables associated with system s for this DofObject

Definition at line 741 of file dof_object.h.

References n_systems(), n_var_groups(), and n_vars().

742 {
743  libmesh_assert_less (s, this->n_systems());
744 
745  const unsigned int nvg = this->n_var_groups(s);
746 
747  unsigned int val=0;
748 
749  for (unsigned int vg=0; vg<nvg; vg++)
750  val += this->n_vars(s,vg);
751 
752  return val;
753 }
DofObject & libMesh::DofObject::operator= ( const DofObject dof_obj)
protected

Deep-copying assignment operator

Definition at line 82 of file dof_object.C.

References _id, _idx_buf, _processor_id, _unique_id, clear_old_dof_object(), dof_number(), DofObject(), n_comp(), n_systems(), n_var_groups(), n_vars(), and old_dof_object.

83 {
84 #ifdef LIBMESH_ENABLE_AMR
85  this->clear_old_dof_object();
86 
87  this->old_dof_object = new DofObject(*(dof_obj.old_dof_object));
88 #endif
89 
90  _id = dof_obj._id;
91 #ifdef LIBMESH_ENABLE_UNIQUE_ID
92  _unique_id = dof_obj._unique_id;
93 #endif
94  _processor_id = dof_obj._processor_id;
95  _idx_buf = dof_obj._idx_buf;
96 
97 
98  // Check that everything worked
99 #ifdef DEBUG
100 
101  libmesh_assert_equal_to (this->n_systems(), dof_obj.n_systems());
102 
103  for (unsigned int s=0; s<this->n_systems(); s++)
104  {
105  libmesh_assert_equal_to (this->n_vars(s), dof_obj.n_vars(s));
106  libmesh_assert_equal_to (this->n_var_groups(s), dof_obj.n_var_groups(s));
107 
108  for (unsigned int vg=0; vg<this->n_var_groups(s); vg++)
109  libmesh_assert_equal_to (this->n_vars(s,vg), dof_obj.n_vars(s,vg));
110 
111  for (unsigned int v=0; v<this->n_vars(s); v++)
112  {
113  libmesh_assert_equal_to (this->n_comp(s,v), dof_obj.n_comp(s,v));
114 
115  for (unsigned int c=0; c<this->n_comp(s,v); c++)
116  libmesh_assert_equal_to (this->dof_number(s,v,c), dof_obj.dof_number(s,v,c));
117  }
118  }
119 
120 #endif
121 
122  return *this;
123 }
void libMesh::DofObject::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 our current implementation.

Definition at line 525 of file dof_object.C.

Referenced by libMesh::Parallel::pack(), libMesh::Node::PackedNode::pack(), and libMesh::Elem::PackedElem::pack().

526 {
527 #ifdef LIBMESH_ENABLE_AMR
528  // We might need to pack old_dof_object too
529  *target++ = (old_dof_object == NULL) ? 0 : 1;
530 #endif
531 
532  *target++ = _idx_buf.size();
533  std::copy(_idx_buf.begin(), _idx_buf.end(), target);
534 
535 #ifdef LIBMESH_ENABLE_AMR
536  if (old_dof_object)
537  old_dof_object->pack_indexing(target);
538 #endif
539 }
unsigned int libMesh::DofObject::packed_indexing_size ( ) const

If we pack our indices into an buffer for communications, how many ints do we need?

Definition at line 448 of file dof_object.C.

References _idx_buf, old_dof_object, and packed_indexing_size().

Referenced by libMesh::Parallel::pack(), libMesh::Parallel::packable_size(), packed_indexing_size(), libMesh::Node::packed_size(), libMesh::Elem::packed_size(), and libMesh::Parallel::unpack().

449 {
450  return
451 #ifdef LIBMESH_ENABLE_AMR
452  ((old_dof_object == NULL) ? 0 : old_dof_object->packed_indexing_size()) + 2 +
453 #else
454  1 +
455 #endif
456  _idx_buf.size();
457 }
void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

Definition at line 88 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

89 {
91 }
processor_id_type libMesh::DofObject::processor_id ( ) const
inline
Returns
the processor that this DofObject belongs to.

When partitioning and DoF numbering have been performed by libMesh, every current DoF on this DofObject will belong to its processor.

Definition at line 673 of file dof_object.h.

References _processor_id.

Referenced by libMesh::MetisPartitioner::_do_partition(), libMesh::LinearPartitioner::_do_partition(), libMesh::SFCPartitioner::_do_partition(), libMesh::CentroidPartitioner::_do_partition(), libMesh::ParallelMesh::add_elem(), libMesh::Patch::add_local_face_neighbors(), libMesh::Patch::add_local_point_neighbors(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::ParallelMesh::add_node(), libMesh::SerialMesh::add_point(), libMesh::ParallelMesh::add_point(), libMesh::UnstructuredMesh::all_first_order(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::Patch::build_around_element(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::UnstructuredMesh::create_submesh(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::Elem::Elem(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::MeshTools::Modification::flatten(), libMesh::Node::get_info(), libMesh::Elem::get_info(), libMesh::DofMap::get_info(), libMesh::DofMap::get_local_constraints(), libMesh::MeshFunction::gradient(), libMesh::MeshFunction::hessian(), invalidate_processor_id(), libMesh::Elem::is_semilocal(), libMesh::MeshTools::libmesh_assert_valid_amr_elem_ids(), libMesh::MeshTools::libmesh_assert_valid_elem_ids(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshFunction::operator()(), libMesh::Parallel::pack(), libMesh::Node::PackedNode::pack(), libMesh::Elem::PackedElem::pack(), libMesh::XdrIO::pack_element(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), processor_id(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::MeshData::read_xdr(), libMesh::Elem::refine(), libMesh::DofMap::scatter_constraints(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_dofobject_data_by_id(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Node::PackedNode::unpack(), libMesh::Parallel::unpack(), libMesh::Elem::PackedElem::unpack(), libMesh::CheckpointIO::write_connectivity(), libMesh::GmshIO::write_mesh(), libMesh::CheckpointIO::write_nodes(), libMesh::XdrIO::write_serialized_connectivity(), and libMesh::Nemesis_IO_Helper::write_sidesets().

674 {
675  return _processor_id;
676 }
processor_id_type & libMesh::DofObject::processor_id ( )
inline
Returns
the processor that this DofObject belongs to as a writeable reference.

Definition at line 681 of file dof_object.h.

References _processor_id.

682 {
683  return _processor_id;
684 }
void libMesh::DofObject::processor_id ( const processor_id_type  pid)
inline

Sets the processor_id for this DofObject.

Definition at line 689 of file dof_object.h.

References processor_id().

690 {
691  this->processor_id() = pid;
692 }
void libMesh::DofObject::set_buffer ( const std::vector< dof_id_type > &  buf)
inline

Definition at line 491 of file dof_object.h.

References _idx_buf.

492  { _idx_buf = buf; }
void libMesh::DofObject::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 with this DofObject

Definition at line 407 of file dof_object.C.

References _idx_buf, dof_number(), invalid_id, libMesh::libmesh_assert(), n_comp(), n_comp_group(), n_systems(), n_vars(), start_idx(), system_var_to_vg_var(), and var_to_vg().

411 {
412  libmesh_assert_less (s, this->n_systems());
413  libmesh_assert_less (var, this->n_vars(s));
414  libmesh_assert_less (comp, this->n_comp(s,var));
415 
416  const unsigned int
417  vg = this->var_to_vg(s,var),
418  ncg = this->n_comp_group(s,vg),
419  vig = this->system_var_to_vg_var(s,vg,var),
420  start_idx_sys = this->start_idx(s);
421 
422  libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
423 
424  dof_id_type &base_idx = _idx_buf[start_idx_sys + 2*vg + 1];
425 
426  // We intend to change all dof numbers together or not at all
427  if (comp || vig)
428  libmesh_assert ((dn == invalid_id && base_idx == invalid_id) ||
429  (dn == base_idx + vig*ncg + comp));
430 
431  // only explicitly store the base index for vig==0, comp==0
432  else
433  base_idx = dn;
434 
435 // #ifdef DEBUG
436 // libMesh::out << " [ ";
437 // for (unsigned int i=0; i<_idx_buf.size(); i++)
438 // libMesh::out << _idx_buf[i] << " ";
439 // libMesh::out << "]\n";
440 // #endif
441 
442  libmesh_assert_equal_to (this->dof_number(s, var, comp), dn);
443 }
void libMesh::DofObject::set_id ( const dof_id_type  dofid)
inline

Sets the id for this DofObject

Definition at line 161 of file dof_object.h.

References set_id().

162  { this->set_id() = dofid; }
void libMesh::DofObject::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 at line 340 of file dof_object.C.

References n_systems(), n_vars(), set_n_comp_group(), and var_to_vg().

343 {
344  libmesh_assert_less (s, this->n_systems());
345  libmesh_assert_less (var, this->n_vars(s));
346 
347  this->set_n_comp_group(s, this->var_to_vg(s,var), ncomp);
348 }
void libMesh::DofObject::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 at line 352 of file dof_object.C.

References _idx_buf, libMesh::err, invalid_id, n_comp_group(), n_systems(), n_var_groups(), n_vars(), ncv_magic, and start_idx().

Referenced by libMesh::DofMap::reinit(), set_n_comp(), set_n_vars_per_group(), and libMesh::DofMap::set_nonlocal_dof_objects().

355 {
356  libmesh_assert_less (s, this->n_systems());
357  libmesh_assert_less (vg, this->n_var_groups(s));
358 
359  // Check for trivial return
360  if (ncomp == this->n_comp_group(s,vg)) return;
361 
362 #ifndef NDEBUG
363  if (ncomp >= ncv_magic)
364  {
365  const index_t ncvm = ncv_magic;
366  libMesh::err << "ERROR: ncomp must be less than DofObject::ncv_magic!\n"
367  << "ncomp = " << ncomp << ", ncv_magic = " << ncvm
368  << "\nrecompile and try again!\n";
369  libmesh_error();
370  }
371 #endif
372 
373  const unsigned int
374  start_idx_sys = this->start_idx(s),
375  n_vars_group = this->n_vars(s,vg),
376  base_offset = start_idx_sys + 2*vg;
377 
378  libmesh_assert_less ((base_offset + 1), _idx_buf.size());
379 
380  // if (ncomp)
381  // libMesh::out << "s,vg,ncomp="
382  // << s << ","
383  // << vg << ","
384  // << ncomp << '\n';
385 
386  // set the number of components, maintaining the number
387  // of variables in the group
388  _idx_buf[base_offset] = ncv_magic*n_vars_group + ncomp;
389 
390  // We use (invalid_id - 1) to signify no
391  // components for this object
392  _idx_buf[base_offset + 1] = (ncomp == 0) ? invalid_id - 1 : invalid_id;
393 
394  // this->debug_buffer();
395  // libMesh::out << "s,vg = " << s << "," << vg << '\n'
396  // << "base_offset=" << base_offset << '\n'
397  // << "this->n_comp(s,vg)=" << this->n_comp(s,vg) << '\n'
398  // << "this->n_comp_group(s,vg)=" << this->n_comp_group(s,vg) << '\n'
399  // << "this->n_vars(s,vg)=" << this->n_vars(s,vg) << '\n'
400  // << "this->n_var_groups(s)=" << this->n_var_groups(s) << '\n';
401 
402  libmesh_assert_equal_to (ncomp, this->n_comp_group(s,vg));
403 }
void libMesh::DofObject::set_n_systems ( const unsigned int  s)

Sets the number of systems for this DofObject

Definition at line 159 of file dof_object.C.

References _idx_buf, clear_dofs(), n_systems(), n_var_groups(), and n_vars().

Referenced by add_system(), and libMesh::Elem::refine().

160 {
161  // Check for trivial return
162  if (ns == this->n_systems())
163  return;
164 
165  // Clear any existing data. This is safe to call
166  // even if we don't have any data.
167  this->clear_dofs();
168 
169  // Set the new number of systems
170  _idx_buf.resize(ns, ns);
171  _idx_buf[0] = ns;
172 
173 
174 #ifdef DEBUG
175 
176  // check that all systems now exist and that they have 0 size
177  libmesh_assert_equal_to (ns, this->n_systems());
178  for (unsigned int s=0; s<this->n_systems(); s++)
179  {
180  libmesh_assert_equal_to (this->n_vars(s), 0);
181  libmesh_assert_equal_to (this->n_var_groups(s), 0);
182  }
183 
184 #endif
185 }
void libMesh::DofObject::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. Implicit in this is salso setting the number of VariableGroup variable groups for the system. Has the effect of setting the number of components to 0 even when called even with (nvg == this->n_var_groups(s)).

Definition at line 221 of file dof_object.C.

References _idx_buf, end, end_idx(), invalid_id, n_comp(), n_comp_group(), n_systems(), n_var_groups(), n_vars(), ncv_magic, set_n_comp_group(), and start_idx().

223 {
224 
225  libmesh_assert_less (s, this->n_systems());
226 
227  // number of varaible groups for this system - inferred
228  const unsigned int nvg = libmesh_cast_int<unsigned int>(nvpg.size());
229 
230  // BSK - note that for compatibility with the previous implementation
231  // calling this method when (nvars == this->n_vars()) requires that
232  // we invalidate the DOF indices and set the number of components to 0.
233  // Note this was a bit of a suprise to me - there was no quick return in
234  // the old method, which caused removal and readdition of the DOF indices
235  // even in the case of (nvars == this->n_vars()), resulting in n_comp(s,v)
236  // implicitly becoming 0 regardless of any previous value.
237  // quick return?
238  if (nvg == this->n_var_groups(s))
239  {
240  for (unsigned int vg=0; vg<nvg; vg++)
241  {
242  this->set_n_comp_group(s,vg,0);
243  libmesh_assert_equal_to (this->n_vars(s,vg), nvpg[vg]);
244  }
245  return;
246  }
247 
248  // since there is ample opportunity to screw up other systems, let us
249  // cache their current sizes and later assert that they are unchanged.
250 #ifdef DEBUG
251  DofObject::index_buffer_t old_system_sizes;
252  old_system_sizes.reserve(this->n_systems());
253 
254  for (unsigned int s_ctr=0; s_ctr<this->n_systems(); s_ctr++)
255  old_system_sizes.push_back(this->n_var_groups(s_ctr));
256 #endif
257 
258  // remove current indices if we have some
259  if (this->n_var_groups(s) != 0)
260  {
261  const unsigned int old_nvg_s = this->n_var_groups(s);
262 
263  DofObject::index_buffer_t::iterator
264  it = _idx_buf.begin(),
265  end = _idx_buf.begin();
266 
267  std::advance(it, this->start_idx(s));
268  std::advance(end, this->end_idx(s));
269  _idx_buf.erase(it,end);
270 
271  for (unsigned int ctr=(s+1); ctr<this->n_systems(); ctr++)
272  _idx_buf[ctr] -= 2*old_nvg_s;
273  }
274 
275  // better not have any now!
276  libmesh_assert_equal_to (this->n_var_groups(s), 0);
277 
278  // had better not screwed up any of our sizes!
279 #ifdef DEBUG
280  for (unsigned int s_ctr=0; s_ctr<this->n_systems(); s_ctr++)
281  if (s_ctr != s)
282  libmesh_assert_equal_to (this->n_var_groups(s_ctr), old_system_sizes[s_ctr]);
283 #endif
284 
285  // OK, if the user requested 0 that is what we have
286  if (nvg == 0)
287  return;
288 
289  {
290  // array to hold new indices
291  DofObject::index_buffer_t var_idxs(2*nvg);
292  for (unsigned int vg=0; vg<nvg; vg++)
293  {
294  var_idxs[2*vg ] = ncv_magic*nvpg[vg] + 0;
295  var_idxs[2*vg + 1] = invalid_id - 1;
296  }
297 
298  DofObject::index_buffer_t::iterator it = _idx_buf.begin();
299  std::advance(it, this->end_idx(s));
300  _idx_buf.insert(it, var_idxs.begin(), var_idxs.end());
301 
302  for (unsigned int ctr=(s+1); ctr<this->n_systems(); ctr++)
303  _idx_buf[ctr] += 2*nvg;
304 
305  // resize _idx_buf to fit so no memory is wasted.
307  }
308 
309  // that better had worked. Assert stuff.
310  libmesh_assert_equal_to (nvg, this->n_var_groups(s));
311 
312 #ifdef DEBUG
313 
314  // libMesh::out << " [ ";
315  // for (unsigned int i=0; i<_idx_buf.size(); i++)
316  // libMesh::out << _idx_buf[i] << " ";
317  // libMesh::out << "]\n";
318 
319  libmesh_assert_equal_to (this->n_var_groups(s), nvpg.size());
320 
321  for (unsigned int vg=0; vg<this->n_var_groups(s); vg++)
322  {
323  libmesh_assert_equal_to (this->n_vars(s,vg), nvpg[vg]);
324  libmesh_assert_equal_to (this->n_comp_group(s,vg), 0);
325  }
326 
327  for (unsigned int v=0; v<this->n_vars(s); v++)
328  libmesh_assert_equal_to (this->n_comp(s,v), 0);
329 
330  // again, all other system sizes shoudl be unchanged!
331  for (unsigned int s_ctr=0; s_ctr<this->n_systems(); s_ctr++)
332  if (s_ctr != s)
333  libmesh_assert_equal_to (this->n_var_groups(s_ctr), old_system_sizes[s_ctr]);
334 
335 #endif
336 }
void libMesh::DofObject::set_old_dof_object ( )

Sets the old_dof_object to a copy of this

Definition at line 144 of file dof_object.C.

References clear_old_dof_object(), DofObject(), libMesh::libmesh_assert(), and old_dof_object.

Referenced by libMesh::DofMap::reinit().

145 {
146  this->clear_old_dof_object();
147 
149 
150  // Make a new DofObject, assign a copy of \p this.
151  // Make sure the copy ctor for DofObject works!!
152  this->old_dof_object = new DofObject(*this);
153 }
unique_id_type & libMesh::DofObject::set_unique_id ( )
inline
Returns
the globally unique_id for this DofObject as a writeable reference.

Definition at line 641 of file dof_object.h.

References _unique_id.

Referenced by libMesh::SerialMesh::add_elem(), libMesh::ParallelMesh::add_elem(), libMesh::SerialMesh::add_node(), libMesh::ParallelMesh::add_node(), libMesh::CheckpointIO::read_connectivity(), libMesh::CheckpointIO::read_nodes(), libMesh::XdrIO::read_serialized_connectivity(), and libMesh::Parallel::unpack().

642 {
643 #ifdef LIBMESH_ENABLE_UNIQUE_ID
644  return _unique_id;
645 #else
646  libmesh_error();
647 #endif
648 }
void libMesh::DofObject::set_vg_dof_base ( const unsigned int  s,
const unsigned int  vg,
const dof_id_type  db 
)
inline

VariableGroup DoF indices are indexed as id = base + var_in_vg*ncomp + comp This method allows for direct access to the base.

Definition at line 881 of file dof_object.h.

References _idx_buf, n_systems(), n_var_groups(), start_idx(), and vg_dof_base().

Referenced by libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), invalidate_dofs(), libMesh::DofMap::reinit(), and libMesh::DofMap::set_nonlocal_dof_objects().

884 {
885  libmesh_assert_less (s, this->n_systems());
886  libmesh_assert_less (vg, this->n_var_groups(s));
887 
888  const unsigned int
889  start_idx_sys = this->start_idx(s);
890 
891  libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
892 
893  _idx_buf[start_idx_sys + 2*vg + 1] = db;
894 
895  libmesh_assert_equal_to (this->vg_dof_base(s,vg), db);
896 }
unsigned int libMesh::DofObject::start_idx ( const unsigned int  s) const
inlineprivate

The starting index for system s.

Definition at line 857 of file dof_object.h.

References _idx_buf, and n_systems().

Referenced by dof_number(), n_comp_group(), n_var_groups(), n_vars(), set_dof_number(), set_n_comp_group(), set_n_vars_per_group(), set_vg_dof_base(), and vg_dof_base().

858 {
859  libmesh_assert_less (s, this->n_systems());
860  libmesh_assert_less (s, _idx_buf.size());
861 
862  return libmesh_cast_int<unsigned int>(_idx_buf[s]);
863 }
unsigned int libMesh::DofObject::system_var_to_vg_var ( const unsigned int  s,
const unsigned int  vg,
const unsigned int  var 
) const
inlineprivate

Utility function - for variable var in system s, figure out what variable group it lives in.

Definition at line 945 of file dof_object.h.

References n_vars().

Referenced by dof_number(), and set_dof_number().

948 {
949  unsigned int accumulated_sum=0;
950 
951  for (unsigned int vgc=0; vgc<vg; vgc++)
952  accumulated_sum += this->n_vars(s,vgc);
953 
954  libmesh_assert_less_equal (accumulated_sum, var);
955 
956  return (var - accumulated_sum);
957 }
unique_id_type libMesh::DofObject::unique_id ( ) const
inline
Returns
the globally unique_id for this DofObject

Definition at line 628 of file dof_object.h.

References _unique_id, invalid_unique_id, libMesh::libmesh_assert(), and valid_unique_id().

Referenced by libMesh::Parallel::pack(), libMesh::XdrIO::pack_element(), libMesh::CheckpointIO::write_connectivity(), and libMesh::CheckpointIO::write_nodes().

629 {
630 #ifdef LIBMESH_ENABLE_UNIQUE_ID
632  return _unique_id;
633 #else
634  return invalid_unique_id;
635 #endif
636 }
void libMesh::DofObject::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 we investigate the size term and then copy.

Definition at line 485 of file dof_object.C.

References _idx_buf, clear_old_dof_object(), DofObject(), libMesh::libmesh_assert(), old_dof_object, and unpack_indexing().

Referenced by libMesh::Node::PackedNode::unpack(), libMesh::Parallel::unpack(), libMesh::Elem::PackedElem::unpack(), and unpack_indexing().

486 {
487  _idx_buf.clear();
488 
489 #ifdef LIBMESH_ENABLE_AMR
490  this->clear_old_dof_object();
491  const int has_old_dof_object = *begin++;
492  libmesh_assert(has_old_dof_object == 1 ||
493  has_old_dof_object == 0);
494 #endif
495 
496  const int size = *begin++;
497  _idx_buf.reserve(size);
498  std::copy(begin, begin+size, back_inserter(_idx_buf));
499 
500  // Check as best we can for internal consistency now
501  libmesh_assert(_idx_buf.empty() ||
502  (_idx_buf[0] <= _idx_buf.size()));
503 #ifdef DEBUG
504  if (!_idx_buf.empty())
505  for (unsigned int i=1; i < _idx_buf[0]; ++i)
506  {
507  libmesh_assert_greater_equal (_idx_buf[i], _idx_buf[i-1]);
508  libmesh_assert_equal_to ((_idx_buf[i] - _idx_buf[i-1])%2, 0);
509  libmesh_assert_less_equal (_idx_buf[i], _idx_buf.size());
510  }
511 #endif
512 
513 #ifdef LIBMESH_ENABLE_AMR
514  if (has_old_dof_object)
515  {
516  this->old_dof_object = new DofObject();
517  this->old_dof_object->unpack_indexing(begin+size);
518  }
519 #endif
520 }
unsigned int libMesh::DofObject::unpackable_indexing_size ( std::vector< largest_id_type >::const_iterator  begin)
static

If we have indices packed into an buffer for communications, how much of that buffer applies to this dof object?

Definition at line 463 of file dof_object.C.

References libMesh::libmesh_assert().

Referenced by libMesh::Parallel::pack(), libMesh::Parallel::packed_size(), libMesh::Elem::PackedElem::packed_size(), and libMesh::Parallel::unpack().

464 {
465 #ifdef LIBMESH_ENABLE_AMR
466  const int has_old_dof_object = *begin++;
467 
468  // Either we have an old_dof_object or we don't
469  libmesh_assert(has_old_dof_object == 1 || has_old_dof_object == 0);
470  static const int dof_header_size = 2;
471 #else
472  static const bool has_old_dof_object = false;
473  static const int dof_header_size = 1;
474 #endif
475 
476  const int this_indexing_size = *begin++;
477 
478  return dof_header_size + this_indexing_size +
479  (has_old_dof_object ?
480  unpackable_indexing_size(begin+this_indexing_size) : 0);
481 }
bool libMesh::DofObject::valid_id ( ) const
inline
bool libMesh::DofObject::valid_processor_id ( ) const
inline
Returns
true if this DofObject has a valid id set, false otherwise.

Definition at line 697 of file dof_object.h.

References _processor_id, and invalid_processor_id.

698 {
700 }
bool libMesh::DofObject::valid_unique_id ( ) const
inline
Returns
true if this DofObject has a valid unique_id set, false otherwise.

Definition at line 661 of file dof_object.h.

References _unique_id, and invalid_unique_id.

Referenced by libMesh::SerialMesh::add_elem(), libMesh::ParallelMesh::add_elem(), libMesh::SerialMesh::add_node(), libMesh::ParallelMesh::add_node(), libMesh::Parallel::pack(), and unique_id().

662 {
663 #ifdef LIBMESH_ENABLE_UNIQUE_ID
665 #else
666  return false;
667 #endif
668 }
unsigned int libMesh::DofObject::var_to_vg ( const unsigned int  s,
const unsigned int  var 
) const
inlineprivate

Utility function - for variable var in system s, figure out what variable group it lives in.

Definition at line 925 of file dof_object.h.

References n_var_groups(), and n_vars().

Referenced by dof_number(), n_comp(), set_dof_number(), and set_n_comp().

927 {
928  const unsigned int
929  nvg = this->n_var_groups(s);
930 
931  for (unsigned int vg=0, vg_end=0; vg<nvg; vg++)
932  {
933  vg_end += this->n_vars(s,vg);
934  if (var < vg_end) return vg;
935  }
936 
937  // we should never get here
938  libmesh_error();
939  return 0;
940 }
dof_id_type libMesh::DofObject::vg_dof_base ( const unsigned int  s,
const unsigned int  vg 
) const
inline

VariableGroup DoF indices are indexed as id = base + var_in_vg*ncomp + comp This method allows for direct access to the base.

Definition at line 901 of file dof_object.h.

References _idx_buf, n_systems(), n_var_groups(), and start_idx().

Referenced by libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::reinit(), libMesh::DofMap::set_nonlocal_dof_objects(), and set_vg_dof_base().

903 {
904  libmesh_assert_less (s, this->n_systems());
905  libmesh_assert_less (vg, this->n_var_groups(s));
906 
907  const unsigned int
908  start_idx_sys = this->start_idx(s);
909 
910  libmesh_assert_less ((start_idx_sys + 2*vg + 1), _idx_buf.size());
911 
912 // #ifdef DEBUG
913 // std::cout << " [ ";
914 // for (unsigned int i=0; i<_idx_buf.size(); i++)
915 // std::cout << _idx_buf[i] << " ";
916 // std::cout << "]\n";
917 // #endif
918 
919  return _idx_buf[start_idx_sys + 2*vg + 1];
920 }

Member Data Documentation

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited
bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 137 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

dof_id_type libMesh::DofObject::_id
private

The id of the DofObject

Definition at line 400 of file dof_object.h.

Referenced by id(), operator=(), set_id(), and valid_id().

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 131 of file reference_counter.h.

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects. Print the reference count information when the number returns to 0.

Definition at line 126 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().

processor_id_type libMesh::DofObject::_processor_id
private

The processor_id of the DofObject. Degrees of freedom are wholly owned by processors, however they may be duplicated on other processors.

This is stored as an unsigned short int since we cannot expect to be solving on 65000+ processors any time soon, can we??

Definition at line 419 of file dof_object.h.

Referenced by operator=(), processor_id(), and valid_processor_id().

unique_id_type libMesh::DofObject::_unique_id
private

A globally unique id, guarenteed not to change as the mesh is repartioned or adapted

Definition at line 407 of file dof_object.h.

Referenced by operator=(), set_unique_id(), unique_id(), and valid_unique_id().

const processor_id_type libMesh::DofObject::invalid_processor_id = static_cast<processor_id_type>(-1)
static

An invalid processor_id to distinguish DoFs that have not been assigned to a processor.

Definition at line 346 of file dof_object.h.

Referenced by libMesh::ParallelMesh::add_elem(), libMesh::ParallelMesh::add_node(), libMesh::MeshCommunication::allgather(), libMesh::MeshTools::bounding_box(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::Elem::Elem(), libMesh::MeshCommunication::find_global_indices(), invalidate_processor_id(), libMesh::ParallelMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::ParallelMesh::n_active_elem(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::MeshBase::n_unpartitioned_elem(), libMesh::MeshBase::n_unpartitioned_nodes(), libMesh::Elem::PackedElem::processor_id(), libMesh::CheckpointIO::read_connectivity(), libMesh::ParallelMesh::renumber_dof_objects(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_dofobject_data_by_id(), libMesh::Parallel::sync_dofobject_data_by_xyz(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::MeshTools::total_weight(), libMesh::Node::PackedNode::unpack(), libMesh::Parallel::unpack(), libMesh::SerialMesh::unpartitioned_elements_begin(), libMesh::ParallelMesh::unpartitioned_elements_begin(), libMesh::SerialMesh::unpartitioned_elements_end(), libMesh::ParallelMesh::unpartitioned_elements_end(), valid_processor_id(), and libMesh::CheckpointIO::write_connectivity().

const unique_id_type libMesh::DofObject::invalid_unique_id = static_cast<unique_id_type>(-1)
static

An invaild unique_id to distinguish an uninitialized DofObject

Definition at line 340 of file dof_object.h.

Referenced by libMesh::Parallel::pack(), libMesh::ParallelMesh::renumber_dof_objects(), unique_id(), and valid_unique_id().

const index_t libMesh::DofObject::ncv_magic = 256
staticprivate

Above we introduced the chimera ncv, which is a hybrid of the form ncv = ncv_magic*nv + nc where nv are the number of identical variables of a given type, and nc is the number of components for this set of variables.

It is hoped that by setting this to a power of two, an optimizing compiler will recgnize later that #/ncv_magic is simply a bitshift

Definition at line 476 of file dof_object.h.

Referenced by n_comp_group(), n_vars(), set_n_comp_group(), and set_n_vars_per_group().

DofObject* libMesh::DofObject::old_dof_object

This object on the last mesh. Useful for projecting solutions from one mesh to another.

Definition at line 89 of file dof_object.h.

Referenced by clear_old_dof_object(), libMesh::MeshTools::libmesh_assert_old_dof_objects(), libMesh::DofMap::old_dof_indices(), operator=(), packed_indexing_size(), libMesh::DofMap::reinit(), set_old_dof_object(), and unpack_indexing().


The documentation for this class was generated from the following files:

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:59 UTC

Hosted By:
SourceForge.net Logo