Poster of Linux kernelThe best gift for a Linux geek
DofObject

DofObject

Section: C Library Functions (3) Updated: Thu Apr 7 2011
Local index Up
 

NAME

DofObject -  

SYNOPSIS


#include <dof_object.h>

Inherits ReferenceCountedObject< DofObject >.

Inherited by Elem, and Node.  

Public Member Functions


DofObject (const DofObject &)

virtual ~DofObject ()

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

unsigned int id () const

unsigned int & set_id ()

void set_id (const unsigned int id)

bool valid_id () const

unsigned short int processor_id () const

unsigned short int & processor_id ()

void processor_id (const unsigned int id)

bool valid_processor_id () const

unsigned int n_systems () const

void set_n_systems (const unsigned int s)

void add_system ()

unsigned int n_vars (const unsigned int s) const

void set_n_vars (const unsigned int s, const unsigned int nvars)

unsigned int n_comp (const unsigned int s, const unsigned int var) const

void set_n_comp (const unsigned int s, const unsigned int var, const unsigned int ncomp)

unsigned int 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 unsigned int dn)

bool has_dofs (const unsigned int s=libMesh::invalid_uint) const

virtual bool operator== (const DofObject &) const
 

Static Public Member Functions


static std::string get_info ()

static void print_info ()

static unsigned int n_objects ()
 

Public Attributes


DofObject * old_dof_object
 

Static Public Attributes


static const unsigned int invalid_id = libMesh::invalid_uint

static const unsigned short int invalid_processor_id = static_cast<unsigned short int>(-1)
 

Protected Types


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

Protected Member Functions


DofObject ()

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
 

Private Attributes


unsigned int _id

unsigned short int _processor_id

unsigned char _n_systems

unsigned char ** _n_v_comp

unsigned int ** _dof_ids
 

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.

This class is intended to be extremely lightweight. To help acheive this goal no std::vector<> or anything else that might be heavy is used to store the degree of freedom indices.

Author:

Benjamin S. Kirk

Date:

2003

Version:

Revision:

3391

Definition at line 53 of file dof_object.h.  

Member Typedef Documentation

 

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > ReferenceCounter::Counts [protected, inherited]Data structure to log the information. The log is identified by the class name.

Definition at line 105 of file reference_counter.h.  

Constructor & Destructor Documentation

 

DofObject::DofObject () [inline, protected]Constructor. Protected so that you can't instantiate one of these.

Definition at line 312 of file dof_object.h.

References invalidate().

Referenced by set_old_dof_object().

                      :
#ifdef LIBMESH_ENABLE_AMR
  old_dof_object(NULL),
#endif
  _id (invalid_id),
  _processor_id (invalid_processor_id),
  _n_systems  (0),
  _n_v_comp (NULL),
  _dof_ids (NULL)
{
  this->invalidate();
}
 

DofObject::DofObject (const DofObject &dof_obj)Copy-constructor.

Definition at line 40 of file dof_object.C.

References _dof_ids, _n_v_comp, dof_number(), invalid_id, n_comp(), n_systems(), and n_vars().

                                              :
  ReferenceCountedObject<DofObject>(),
#ifdef LIBMESH_ENABLE_AMR
  old_dof_object (NULL),
#endif
  _id            (dof_obj._id),
  _processor_id  (dof_obj._processor_id),
  _n_systems     (dof_obj._n_systems),
  _n_v_comp      (NULL),
  _dof_ids       (NULL)
{

  // Allocate storage for the dof numbers and copy
  // the values. 
  // IT IS UNDEFINED BEHAVIOR TO ALLOCATE AN ARRAY WITH ZERO ENTRIES,
  // IF n_systems==0, leave _n_v_comp, and _dof_ids NULL.
  if (this->n_systems() > 0)
    {
      _n_v_comp = new unsigned char* [this->n_systems()];
      _dof_ids  = new unsigned int*  [this->n_systems()];

      // gotta specifically NULL these - we rely later that
      // _n_v_comp[s] == NULL is synonymous with no variables in the system.
      for (unsigned int s=0; s<this->n_systems(); s++)
        {
          _n_v_comp[s] = NULL;
          _dof_ids[s]  = NULL;
        }      
    }

  // If n_systems==0, we don't enter this for loop.
  for (unsigned int s=0; s<this->n_systems(); s++)
    {
      // In case you have a system with no variables, it is undefined
      // behavior (UB) to allocate a zero-length array here.
      if (dof_obj.n_vars(s) > 0)
        {
          _n_v_comp[s] = new unsigned char [dof_obj.n_vars(s)+1]; 
          _dof_ids[s]  = new unsigned int  [dof_obj.n_vars(s)];
          
          _n_v_comp[s][0] = dof_obj.n_vars(s);

        }
      for (unsigned int v=0; v<this->n_vars(s); v++)
        {
          _n_v_comp[s][v+1]  = dof_obj.n_comp(s,v);

          if (this->n_comp(s,v) > 0)
            _dof_ids[s][v] = dof_obj.dof_number(s,v,0);
          else
            _dof_ids[s][v] = invalid_id;
        }
    }

  // Check that everything worked
#ifdef DEBUG

  libmesh_assert (this->n_systems() == dof_obj.n_systems());

  for (unsigned int s=0; s<this->n_systems(); s++)
    {
      libmesh_assert (this->n_vars(s) == dof_obj.n_vars(s));

      for (unsigned int v=0; v<this->n_vars(s); v++)
        {
          libmesh_assert (this->n_comp(s,v) == dof_obj.n_comp(s,v));

          for (unsigned int c=0; c<this->n_comp(s,v); c++)
            libmesh_assert (this->dof_number(s,v,c) == dof_obj.dof_number(s,v,c));
        }
    }
  
#endif
}
 

DofObject::~DofObject () [inline, virtual]Destructor.

Definition at line 330 of file dof_object.h.

References clear_dofs(), and clear_old_dof_object().

{
  // Free all memory.
#ifdef LIBMESH_ENABLE_AMR
  this->clear_old_dof_object ();
#endif
  this->clear_dofs ();
}
 

Member Function Documentation

 

void DofObject::add_system ()Adds an additional system to the DofObject

Definition at line 188 of file dof_object.C.

References _dof_ids, _n_systems, _n_v_comp, and n_systems().

{
  if (this->n_systems() > 0)
    {
      // Copy the old systems to temporary storage
      unsigned char **old_n_v_comp = new unsigned char* [this->n_systems()];
      unsigned int  **old_dof_ids  = new unsigned int*  [this->n_systems()]; 
      
      for (unsigned int s=0; s<this->n_systems(); s++)
        {
          old_n_v_comp[s] = _n_v_comp[s];
          old_dof_ids[s]  = _dof_ids[s];
        }
      
      // Delete old storage
      libmesh_assert (_n_v_comp != NULL); delete [] _n_v_comp; _n_v_comp = NULL;
      libmesh_assert (_dof_ids  != NULL); delete [] _dof_ids;  _dof_ids  = NULL;
  
      // Allocate space for new system
      _n_v_comp= new unsigned char* [this->n_systems()+1];
      _dof_ids = new unsigned int*  [this->n_systems()+1];
      
      // Copy the other systems
      for (unsigned int s=0; s<this->n_systems(); s++)
        {
          _n_v_comp[s] = old_n_v_comp[s];
          _dof_ids[s]  = old_dof_ids[s];
        }
               
      // Delete temporary storage
      libmesh_assert (old_n_v_comp != NULL); delete [] old_n_v_comp; old_n_v_comp = NULL;
      libmesh_assert (old_dof_ids  != NULL); delete [] old_dof_ids;  old_dof_ids  = NULL;
    }
  else
    {
      libmesh_assert (_n_v_comp == NULL);
      libmesh_assert (_dof_ids  == NULL);
      
      // Allocate space for new system
      _n_v_comp = new unsigned char* [this->n_systems()+1];
      _dof_ids  = new unsigned int*  [this->n_systems()+1];      
    }
  
  // Initialize the new system
  _n_v_comp[this->n_systems()] = NULL;
  _dof_ids[this->n_systems()]  = NULL;
  
  // Done. Don't forget to increment the number of systems!
  _n_systems++;
}
 

void DofObject::clear_dofs () [inline]Clear the DofMap data structures and return to a pristine state.

Definition at line 388 of file dof_object.h.

References _dof_ids, _n_systems, _n_v_comp, and n_systems().

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

{
  // Only clear if there is data
  if (this->n_systems() != 0)
    {
      libmesh_assert (_n_v_comp != NULL);
      libmesh_assert (_dof_ids  != NULL);
      
      for (unsigned int s=0; s<this->n_systems(); s++)
        {
          if (_dof_ids[s] != NULL) // This has only been allocated if 
            {                      // variables were declared
              delete [] _dof_ids[s]; _dof_ids[s] = NULL;
            }
          
          if (_n_v_comp[s] != NULL) // it is possible the number of variables is 0,
            {                       // but this was allocated (_n_v_comp[s][0] == 0)
              delete [] _n_v_comp[s]; _n_v_comp[s] = NULL;
            }
        }
      
      delete [] _n_v_comp; _n_v_comp = NULL;
      delete [] _dof_ids;  _dof_ids  = NULL;
    }
  
  // Make sure we cleaned up
  // (or there was nothing there)
  libmesh_assert (_n_v_comp == NULL);
  libmesh_assert (_dof_ids  == NULL);
  
  // No systems now.
  _n_systems = 0;
}
 

void DofObject::clear_old_dof_object ()Sets the old_dof_object to NULL

Definition at line 120 of file dof_object.C.

References old_dof_object.

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

{
  // If we have been called before...
  // prevent a memory leak
  if (old_dof_object != NULL)
    {
      delete this->old_dof_object;
      this->old_dof_object = NULL;
    }  
}
 

unsigned int DofObject::dof_number (const unsigned ints, const unsigned intvar, const unsigned intcomp) const [inline]Returns:

the global degree of freedom number variable var, component comp for system s associated with this DofObject

Definition at line 564 of file dof_object.h.

References _dof_ids, invalid_id, n_comp(), n_systems(), and n_vars().

Referenced by DofMap::constrain_p_dofs(), GMVIO::copy_nodal_solution(), DofMap::distribute_local_dofs_node_major(), DofMap::distribute_local_dofs_var_major(), DofMap::dof_indices(), DofObject(), DofMap::old_dof_indices(), DofMap::reinit(), HPCoarsenTest::select_refinement(), set_dof_number(), DofMap::set_nonlocal_dof_objects(), VTKIO::solution_to_vtk(), and System::zero_variable().

{
  libmesh_assert (s < this->n_systems());
  libmesh_assert (var  < this->n_vars(s));
  libmesh_assert (_dof_ids != NULL);
  libmesh_assert (_dof_ids[s] != NULL);  
  libmesh_assert (comp < this->n_comp(s,var));
  
  if (_dof_ids[s][var] == invalid_id)
    return invalid_id;
  else
    return (_dof_ids[s][var] + comp);
}
 

std::string ReferenceCounter::get_info () [static, inherited]Gets a string containing the reference information.

Definition at line 45 of file reference_counter.C.

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

Referenced by ReferenceCounter::print_info().

{
#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)

  std::ostringstream out;
  
  out << '
      << ' ---------------------------------------------------------------------------- 
      << '| Reference count information                                                |
      << ' ---------------------------------------------------------------------------- ;
  
  for (Counts::iterator it = _counts.begin();
       it != _counts.end(); ++it)
    {
      const std::string name(it->first);
      const unsigned int creations    = it->second.first;
      const unsigned int destructions = it->second.second;

      out << '| ' << name << ' reference count information:
          << '|  Creations:    ' << creations    << '
          << '|  Destructions: ' << destructions << ';
    }
  
  out << ' ---------------------------------------------------------------------------- ;

  return out.str();

#else

  return '';
  
#endif
}
 

bool DofObject::has_dofs (const unsigned ints = libMesh::invalid_uint) const [inline]Returns:

true if any system has variables which have been assigned, false otherwise

Definition at line 583 of file dof_object.h.

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

Referenced by DofMap::reinit().

{
  if (sys == libMesh::invalid_uint)
    {
      for (unsigned int s=0; s<this->n_systems(); s++)
        if (this->n_vars(s))
          return true;
    }
  
  else
    {
      libmesh_assert (sys < this->n_systems());

      if (this->n_vars(sys))
        return true;
    }
  
  return false;
}
 

unsigned int DofObject::id () const [inline]Returns:

the id for this DofObject

Definition at line 449 of file dof_object.h.

References _id, and valid_id().

Referenced by SFCPartitioner::_do_partition(), UniformRefinementEstimator::_estimate_error(), SerialMesh::add_elem(), ParallelMesh::add_elem(), SerialMesh::add_node(), ParallelMesh::add_node(), ParallelMesh::add_point(), UnstructuredMesh::all_first_order(), UnstructuredMesh::all_second_order(), FEMSystem::assembly(), MeshData::assign(), ParmetisPartitioner::assign_partitioning(), MeshTools::Generation::build_delaunay_square(), ParmetisPartitioner::build_graph(), InfElemBuilder::build_inf_elem(), VTKIO::cells_to_vtk(), FEBase::compute_single_point_map(), UnstructuredMesh::copy_nodes_and_elements(), MeshRefinement::create_parent_error_vector(), SerialMesh::delete_elem(), ParallelMesh::delete_elem(), SerialMesh::delete_node(), ParallelMesh::delete_node(), MeshCommunication::delete_remote_elements(), MeshData::elem_to_foreign_id(), JumpErrorEstimator::estimate_error(), ExactErrorEstimator::estimate_error(), UnstructuredMesh::find_neighbors(), MeshTools::find_nodal_neighbors(), MeshRefinement::flag_elements_by_elem_fraction(), MeshRefinement::flag_elements_by_error_fraction(), MeshRefinement::flag_elements_by_error_tolerance(), MeshRefinement::flag_elements_by_mean_stddev(), TetGenMeshInterface::get_node_index(), LaplaceMeshSmoother::init(), ParmetisPartitioner::initialize(), ExodusII_IO_Helper::initialize(), TreeNode< N >::insert(), SerialMesh::insert_elem(), ParallelMesh::insert_elem(), ParallelMesh::insert_node(), FE< Dim, T >::inverse_map(), Elem::is_ancestor_of(), MeshTools::libmesh_assert_valid_elem_ids(), MeshTools::libmesh_assert_valid_node_procids(), MeshTools::libmesh_assert_valid_refinement_flags(), Node::Node(), Elem::node(), MeshData::node_to_foreign_id(), VTKIO::nodes_to_vtk(), PatchRecoveryErrorEstimator::EstimateError::operator()(), XdrIO::pack_element(), ErrorVector::plot_error(), processor_id(), Nemesis_IO::read(), ExodusII_IO::read(), ParallelMesh::renumber_elem(), ParallelMesh::renumber_node(), ParallelMesh::renumber_nodes_and_elements(), HPCoarsenTest::select_refinement(), set_id(), Partitioner::set_node_processor_ids(), DofMap::set_nonlocal_dof_objects(), Partitioner::set_parent_processor_ids(), FE< Dim, T >::shape(), FE< Dim, T >::shape_deriv(), FE< Dim, T >::shape_second_deriv(), LaplaceMeshSmoother::smooth(), MeshTools::Modification::smooth(), BoundaryInfo::sync(), Parallel::sync_dofobject_data_by_id(), Parallel::sync_element_data_by_parent_id(), GMVIO::write_ascii_new_impl(), GMVIO::write_ascii_old_impl(), ExodusII_IO_Helper::write_elements(), LegacyXdrIO::write_mesh(), GmshIO::write_mesh(), and XdrIO::write_serialized_connectivity().

{
  libmesh_assert (this->valid_id());
  return _id;
}
 

void ReferenceCounter::increment_constructor_count (const std::string &name) [inline, protected, inherited]Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.

Definition at line 149 of file reference_counter.h.

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

Referenced by ReferenceCountedObject< Value >::ReferenceCountedObject().

{
  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
  std::pair<unsigned int, unsigned int>& p = _counts[name];

  p.first++;
}
 

void ReferenceCounter::increment_destructor_count (const std::string &name) [inline, protected, inherited]Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.

Definition at line 167 of file reference_counter.h.

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

Referenced by ReferenceCountedObject< Value >::~ReferenceCountedObject().

{
  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
  std::pair<unsigned int, unsigned int>& p = _counts[name];

  p.second++;
}
 

void DofObject::invalidate () [inline]Invalidates all the indices for this DofObject

Definition at line 378 of file dof_object.h.

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

Referenced by DofObject().

{
  this->invalidate_dofs ();
  this->invalidate_id ();
  this->invalidate_processor_id ();
}
 

void DofObject::invalidate_dofs (const unsigned intsys_num = libMesh::invalid_uint) [inline]Sets all degree of freedom numbers to invalid_id

Definition at line 342 of file dof_object.h.

References invalid_id, n_comp(), n_systems(), n_vars(), and set_dof_number().

Referenced by invalidate().

{
  // If the user does not specify the system number...
  if (sys_num >= this->n_systems()) 
    {
      for (unsigned int s=0; s<this->n_systems(); s++)
        for (unsigned int v=0; v<this->n_vars(s); v++)
          if (this->n_comp(s,v))
            this->set_dof_number(s,v,0,invalid_id);
    }
  // ...otherwise invalidate the dofs for all systems
  else
    for (unsigned int v=0; v<n_vars(sys_num); v++)
      if (this->n_comp(sys_num,v))
        this->set_dof_number(sys_num,v,0,invalid_id);
}
 

void DofObject::invalidate_id () [inline]Sets the id to invalid_id

Definition at line 362 of file dof_object.h.

References invalid_id, and set_id().

Referenced by invalidate().

{
  this->set_id (invalid_id);
}
 

void DofObject::invalidate_processor_id () [inline]Sets the processor id to invalid_processor_id

Definition at line 370 of file dof_object.h.

References invalid_processor_id, and processor_id().

Referenced by MeshTools::correct_node_proc_ids(), invalidate(), Partitioner::set_node_processor_ids(), and Partitioner::set_parent_processor_ids().

{
  this->processor_id (invalid_processor_id);
}
 

unsigned int DofObject::n_comp (const unsigned ints, const unsigned intvar) 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 dof's associated with one node. Another example is the MONOMIALs, where only the elements hold the dof's, but for the different spatial directions, and orders, see FE.

Definition at line 538 of file dof_object.h.

References _dof_ids, _n_v_comp, n_systems(), and n_vars().

Referenced by DofMap::constrain_p_dofs(), DofMap::distribute_local_dofs_node_major(), DofMap::distribute_local_dofs_var_major(), DofMap::dof_indices(), dof_number(), DofObject(), invalidate_dofs(), n_dofs(), DofMap::old_dof_indices(), DofMap::reinit(), set_dof_number(), set_n_comp(), DofMap::set_nonlocal_dof_objects(), and System::zero_variable().

{
  libmesh_assert (s < this->n_systems());
  libmesh_assert (_dof_ids != NULL);
  libmesh_assert (_dof_ids[s] != NULL);
  libmesh_assert (_n_v_comp != NULL);
  libmesh_assert (_n_v_comp[s] != NULL);

# ifdef DEBUG
  // Does this ever happen?  I doubt it... 3/7/2003 (BSK)
  if (var >= this->n_vars(s))
    {
      std::cout << 's=' << s << ', var=' << var << std::endl
                << 'this->n_vars(s)=' << this->n_vars(s) << std::endl
                << 'this->n_systems()=' << this->n_systems() << std::endl;
      libmesh_error();
    }
# endif
  
  return static_cast<unsigned int>(_n_v_comp[s][var+1]);
}
 

unsigned int DofObject::n_dofs (const unsigned ints, const unsigned intvar = 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 425 of file dof_object.h.

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

{
  libmesh_assert (s < this->n_systems());
  
  unsigned int num = 0;

  // Count all variables
  if (var == libMesh::invalid_uint)
    for (unsigned int v=0; v<this->n_vars(s); v++)
      num += this->n_comp(s,v);
  
  // Only count specified variable
  else
    {
      num = this->n_comp(s,var);
    }

  return num;
}
 

static unsigned int ReferenceCounter::n_objects () [inline, static, inherited]Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 76 of file reference_counter.h.

References ReferenceCounter::_n_objects.

Referenced by System::read_serialized_blocked_dof_objects(), and System::write_serialized_blocked_dof_objects().

  { return _n_objects; }
 

unsigned int DofObject::n_systems () const [inline]Returns:

the number of systems associated with this DofObject

Definition at line 517 of file dof_object.h.

References _n_systems.

Referenced by add_system(), clear_dofs(), DofMap::dof_indices(), dof_number(), DofObject(), has_dofs(), invalidate_dofs(), n_comp(), n_dofs(), n_vars(), DofMap::old_dof_indices(), Elem::refine(), set_dof_number(), set_n_comp(), set_n_systems(), and set_n_vars().

{
  return static_cast<unsigned int>(_n_systems);
}
 

unsigned int DofObject::n_vars (const unsigned ints) const [inline]Returns:

the number of variables associated with system s for this DofObject

Definition at line 525 of file dof_object.h.

References _n_v_comp, and n_systems().

Referenced by DofMap::distribute_local_dofs_node_major(), DofMap::distribute_local_dofs_var_major(), dof_number(), DofObject(), has_dofs(), invalidate_dofs(), n_comp(), n_dofs(), set_dof_number(), set_n_comp(), set_n_vars(), and DofMap::set_nonlocal_dof_objects().

{
  libmesh_assert (s < this->n_systems());
  libmesh_assert (_n_v_comp != NULL);
  if (_n_v_comp[s] == NULL)
    return 0;
  return static_cast<unsigned int>(_n_v_comp[s][0]);
}
 

virtual bool DofObject::operator== (const DofObject &) const [inline, virtual]Implemented in Elem and Node.

Reimplemented in Elem, and Node.

Definition at line 250 of file dof_object.h.

  { libmesh_error(); return false; }
 

void ReferenceCounter::print_info () [static, inherited]Prints the reference information to std::cout.

Definition at line 83 of file reference_counter.C.

References ReferenceCounter::get_info().

{
#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
  
  std::cout << ReferenceCounter::get_info();
  
#endif
}
 

void DofObject::processor_id (const unsigned intid) [inline]Sets the processor_id for this DofObject.

Definition at line 489 of file dof_object.h.

References id(), and processor_id().

{
#ifdef DEBUG
  
  if (id != static_cast<unsigned int>(static_cast<unsigned short int>(id)))
    {
      std::cerr << 'ERROR: id too large for unsigned short int!' << std::endl
                << 'Recompile with DofObject::_processor_id larger!' << std::endl;
      
      libmesh_error();
    }

#endif
  
  this->processor_id() = id;
}
 

unsigned short int & DofObject::processor_id () [inline]Returns:

the processor that this element belongs to as a writeable reference.

Definition at line 481 of file dof_object.h.

References _processor_id.

{
  return _processor_id;
}
 

unsigned short int DofObject::processor_id () const [inline]Returns:

the processor that this element belongs to. To conserve space this is stored as a short integer.

Definition at line 473 of file dof_object.h.

References _processor_id.

Referenced by SFCPartitioner::_do_partition(), MetisPartitioner::_do_partition(), LinearPartitioner::_do_partition(), CentroidPartitioner::_do_partition(), GMVIO::_read_materials(), ParallelMesh::add_elem(), Patch::add_local_face_neighbors(), Patch::add_local_point_neighbors(), DofMap::add_neighbors_to_send_list(), ParallelMesh::add_node(), SerialMesh::add_point(), ParallelMesh::add_point(), UnstructuredMesh::all_first_order(), UnstructuredMesh::all_second_order(), MeshTools::Modification::all_tri(), ParmetisPartitioner::assign_partitioning(), Patch::build_around_element(), InfElemBuilder::build_inf_elem(), UnstructuredMesh::copy_nodes_and_elements(), MeshTools::correct_node_proc_ids(), UnstructuredMesh::create_submesh(), DofMap::distribute_local_dofs_node_major(), DofMap::distribute_local_dofs_var_major(), Elem::Elem(), UnstructuredMesh::find_neighbors(), MeshTools::Modification::flatten(), invalidate_processor_id(), Elem::is_ancestor_of(), MeshTools::libmesh_assert_valid_elem_ids(), MeshRefinement::make_coarsening_compatible(), XdrIO::pack_element(), Partitioner::partition_unpartitioned_elements(), processor_id(), Nemesis_IO::read(), XdrIO::read_serialized_connectivity(), MeshData::read_xdr(), Elem::refine(), Partitioner::set_node_processor_ids(), DofMap::set_nonlocal_dof_objects(), Partitioner::set_parent_processor_ids(), BoundaryInfo::sync(), Parallel::sync_dofobject_data_by_id(), Parallel::sync_element_data_by_parent_id(), GmshIO::write_mesh(), and XdrIO::write_serialized_connectivity().

{
  return _processor_id;
}
 

void DofObject::set_dof_number (const unsigned ints, const unsigned intvar, const unsigned intcomp, const unsigned intdn)Sets the global degree of freedom number variable var, component comp for system s associated with this DofObject

Definition at line 338 of file dof_object.C.

References _dof_ids, dof_number(), invalid_id, n_comp(), n_systems(), and n_vars().

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

{
  libmesh_assert (s < this->n_systems());
  libmesh_assert (var  < this->n_vars(s));
  libmesh_assert (_dof_ids != NULL);
  libmesh_assert (_dof_ids[s] != NULL);
  libmesh_assert (comp < this->n_comp(s,var));
  
  //We intend to change all dof numbers together or not at all
  if (comp)
    libmesh_assert ((dn == invalid_id && _dof_ids[s][var] == invalid_id) || 
                    (dn == _dof_ids[s][var] + comp));
  else
    _dof_ids[s][var] = dn;


  libmesh_assert(this->dof_number(s, var, comp) == dn);
}
 

unsigned int & DofObject::set_id () [inline]Returns:

the id for this DofObject as a writeable reference.

Definition at line 458 of file dof_object.h.

References _id.

Referenced by GMVIO::_read_one_cell(), SerialMesh::add_elem(), ParallelMesh::add_elem(), SerialMesh::add_node(), ParallelMesh::add_node(), UnstructuredMesh::all_first_order(), MeshCommunication::assign_global_indices(), InfElemBuilder::build_inf_elem(), UNVIO::element_in(), invalidate_id(), Node::Node(), VTKIO::read(), Nemesis_IO::read(), UCDIO::read_implementation(), LegacyXdrIO::read_mesh(), GmshIO::read_mesh(), XdrIO::read_serialized_connectivity(), OFFIO::read_stream(), MatlabIO::read_stream(), SerialMesh::renumber_elem(), ParallelMesh::renumber_elem(), SerialMesh::renumber_node(), ParallelMesh::renumber_node(), and SerialMesh::renumber_nodes_and_elements().

{
  return _id;
}
 

void DofObject::set_id (const unsigned intid) [inline]Sets the id for this DofObject

Definition at line 143 of file dof_object.h.

References id(), and set_id().

Referenced by set_id().

  { this->set_id() = id; }
 

void DofObject::set_n_comp (const unsigned ints, const unsigned intvar, const unsigned intncomp)Sets the number of components for variable var of system s associated with this DofObject

Definition at line 298 of file dof_object.C.

References _dof_ids, _n_v_comp, invalid_id, n_comp(), n_systems(), and n_vars().

Referenced by DofMap::reinit(), and DofMap::set_nonlocal_dof_objects().

{
  libmesh_assert (s < this->n_systems());
  libmesh_assert (var < this->n_vars(s));
  libmesh_assert (_dof_ids != NULL);
  libmesh_assert (_dof_ids[s] != NULL);
  
  // Check for trivial return
  if (ncomp == this->n_comp(s,var)) return;

#ifdef DEBUG

  if (ncomp != static_cast<unsigned int>(static_cast<unsigned char>(ncomp)))
    {
      std::cerr << 'Unsigned char not big enough to hold ncomp!' << std::endl
                << 'Recompile with _n_v_comp set to a bigger type!'
                << std::endl;
      
      libmesh_error();
    }
  
#endif

  // We use (invalid_id - 1) to signify no
  // components for this object
  if (ncomp == 0)
    {
      _dof_ids[s][var] = (invalid_id - 1);
    }
  
  libmesh_assert (_n_v_comp    != NULL);
  libmesh_assert (_n_v_comp[s] != NULL);
    
  _n_v_comp[s][var+1]  = static_cast<unsigned char>(ncomp);
}
 

void DofObject::set_n_systems (const unsigned ints)Sets the number of systems for this DofObject

Definition at line 148 of file dof_object.C.

References _dof_ids, _n_systems, _n_v_comp, clear_dofs(), and n_systems().

Referenced by Elem::refine().

{
  // Check for trivial return
  if (ns == this->n_systems()) return;
 
#ifdef DEBUG

  if (ns != static_cast<unsigned int>(static_cast<unsigned char>(ns)))
    {
      std::cerr << 'Unsigned char not big enough to hold ns!' << std::endl
                << 'Recompile with _n_systems set to a bigger type!'
                << std::endl;
      
      libmesh_error();
    }
                                        
#endif


  // Clear any existing data.  This is safe to call
  // even if we don't have any data.
  this->clear_dofs();

  // Set the new number of systems
  _n_systems = static_cast<unsigned char>(ns);
  
  // Allocate storage for the systems
  _n_v_comp = new unsigned char* [this->n_systems()];
  _dof_ids  = new unsigned int*  [this->n_systems()];

  // No variables have been declared yet.
  for (unsigned int s=0; s<this->n_systems(); s++)
    {
      _n_v_comp[s] = NULL;
      _dof_ids[s]  = NULL;
    }
}
 

void DofObject::set_n_vars (const unsigned ints, const unsigned intnvars)Sets number of variables associated with system s for this DofObject

Definition at line 241 of file dof_object.C.

References _dof_ids, _n_v_comp, invalid_id, n_systems(), and n_vars().

{
  libmesh_assert (s < this->n_systems());
  libmesh_assert (_n_v_comp != NULL);
  libmesh_assert (_dof_ids  != NULL);

#ifdef DEBUG

  if (nvars != static_cast<unsigned int>(static_cast<unsigned char>(nvars)))
    {
      std::cerr << 'Unsigned char not big enough to hold nvar!' << std::endl
                << 'Recompile with _n_vars set to a bigger type!'
                << std::endl;
      
      libmesh_error();
    }
                                        
#endif

  
  
  // If we already have memory allocated clear it.
  if (this->n_vars(s) != 0)
    {
      libmesh_assert (_n_v_comp[s] != NULL); delete [] _n_v_comp[s]; _n_v_comp[s] = NULL;
      libmesh_assert (_dof_ids[s]  != NULL); delete [] _dof_ids[s];  _dof_ids[s]  = NULL;
    }

  // Reset the number of variables in the system  
  if (nvars > 0)
    {
      libmesh_assert (_n_v_comp[s] == NULL);
      libmesh_assert (_dof_ids[s]  == NULL);
      
      _n_v_comp[s] = new unsigned char [nvars+1];
      _dof_ids[s]  = new unsigned int  [nvars];
      
      _n_v_comp[s][0] = static_cast<unsigned char>(nvars);

      libmesh_assert (nvars == this->n_vars(s));
      
      for (unsigned int v=0; v<this->n_vars(s); v++)
        {
          _n_v_comp[s][v+1] = 0;
          _dof_ids[s][v]    = invalid_id - 1;
        }
    }
  else // (nvars == 0)
    {
      libmesh_assert (_n_v_comp[s] == NULL);
      libmesh_assert (_dof_ids[s]  == NULL);
    }
}
 

void DofObject::set_old_dof_object ()Sets the old_dof_object to a copy of this

Definition at line 133 of file dof_object.C.

References clear_old_dof_object(), DofObject(), and old_dof_object.

Referenced by DofMap::reinit().

{
  this->clear_old_dof_object();

  libmesh_assert (this->old_dof_object == NULL);
  
  // Make a new DofObject, assign a copy of 
this. // Make sure the copy ctor for DofObject works!! this->old_dof_object = new DofObject(*this); }
 

bool DofObject::valid_id () const [inline]Returns:

true if this DofObject has a valid id set, false otherwise.

Definition at line 466 of file dof_object.h.

References _id, and invalid_id.

Referenced by SerialMesh::add_elem(), ParallelMesh::add_elem(), SerialMesh::add_node(), ParallelMesh::add_node(), id(), and Elem::libmesh_assert_valid_node_pointers().

{
  return (DofObject::invalid_id != _id);
}
 

bool DofObject::valid_processor_id () const [inline]Returns:

true if this DofObject has a valid id set, false otherwise.

Definition at line 509 of file dof_object.h.

References _processor_id, and invalid_processor_id.

{
  return (DofObject::invalid_processor_id != _processor_id);
}
 

Member Data Documentation

 

ReferenceCounter::Counts ReferenceCounter::_counts [static, protected, inherited]Actually holds the data.

Definition at line 110 of file reference_counter.h.

Referenced by ReferenceCounter::get_info(), ReferenceCounter::increment_constructor_count(), and ReferenceCounter::increment_destructor_count().  

unsigned int** DofObject::_dof_ids [private]The first global degree of freedom number for each variable of each system.

Definition at line 304 of file dof_object.h.

Referenced by add_system(), clear_dofs(), dof_number(), DofObject(), n_comp(), set_dof_number(), set_n_comp(), set_n_systems(), and set_n_vars().  

unsigned int DofObject::_id [private]The id of the DofObject

Definition at line 272 of file dof_object.h.

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

Threads::spin_mutex ReferenceCounter::_mutex [static, protected, inherited]Mutual exclusion object to enable thread-safe reference counting.

Definition at line 123 of file reference_counter.h.  

Threads::atomic< unsigned int > ReferenceCounter::_n_objects [static, protected, inherited]The number of objects. Print the reference count information when the number returns to 0.

Definition at line 118 of file reference_counter.h.

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

unsigned char DofObject::_n_systems [private]The number of systems.

Definition at line 288 of file dof_object.h.

Referenced by add_system(), clear_dofs(), n_systems(), and set_n_systems().  

unsigned char** DofObject::_n_v_comp [private]The number of variables and components for each variable of each system associated with this DofObject. This is stored as an unsigned char for storage efficiency.

_n_v_comp[s][0] = # of variables in system s _n_v_comp[s][v+1] = # of components for variable v in system s.

Definition at line 298 of file dof_object.h.

Referenced by add_system(), clear_dofs(), DofObject(), n_comp(), n_vars(), set_n_comp(), set_n_systems(), and set_n_vars().  

unsigned short int 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 283 of file dof_object.h.

Referenced by processor_id(), and valid_processor_id().  

const unsigned int DofObject::invalid_id = libMesh::invalid_uint [static]An invaild id to distinguish an uninitialized DofObject

Definition at line 257 of file dof_object.h.

Referenced by Node::active(), SerialMesh::add_point(), MeshRefinement::add_point(), UnstructuredMesh::all_second_order(), FEBase::compute_periodic_constraints(), FEBase::compute_proj_constraints(), DofMap::distribute_local_dofs_node_major(), DofMap::distribute_local_dofs_var_major(), DofMap::dof_indices(), dof_number(), DofObject(), invalidate_dofs(), invalidate_id(), ParallelMesh::libmesh_assert_valid_parallel_object_ids(), Node::Node(), Elem::node(), DofMap::old_dof_indices(), Elem::point(), System::read_legacy_data(), System::read_parallel_data(), set_dof_number(), set_n_comp(), set_n_vars(), DofMap::set_nonlocal_dof_objects(), valid_id(), DofMap::variable_first_local_dof(), DofMap::variable_last_local_dof(), and System::write_parallel_data().  

const unsigned short int DofObject::invalid_processor_id = static_cast<unsigned short int>(-1) [static]An invalid processor_id to distinguish DOFs that have not been assigned to a processor.

Definition at line 263 of file dof_object.h.

Referenced by ParallelMesh::add_elem(), ParallelMesh::add_node(), MeshTools::bounding_box(), MeshTools::correct_node_proc_ids(), Elem::Elem(), MeshCommunication::find_global_indices(), invalidate_processor_id(), ParallelMesh::libmesh_assert_valid_parallel_object_ids(), ParallelMesh::n_active_elem(), MeshBase::n_elem_on_proc(), MeshBase::n_nodes_on_proc(), MeshBase::n_unpartitioned_elem(), MeshBase::n_unpartitioned_nodes(), ParallelMesh::renumber_dof_objects(), Partitioner::set_node_processor_ids(), DofMap::set_nonlocal_dof_objects(), Partitioner::set_parent_processor_ids(), Parallel::sync_dofobject_data_by_id(), Parallel::sync_dofobject_data_by_xyz(), Parallel::sync_element_data_by_parent_id(), MeshTools::total_weight(), SerialMesh::unpartitioned_elements_begin(), ParallelMesh::unpartitioned_elements_begin(), SerialMesh::unpartitioned_elements_end(), ParallelMesh::unpartitioned_elements_end(), and valid_processor_id().  

DofObject* DofObject::old_dof_objectThis object on the last mesh. Useful for projecting solutions from one mesh to another.

Definition at line 81 of file dof_object.h.

Referenced by clear_old_dof_object(), DofMap::old_dof_indices(), DofMap::reinit(), and set_old_dof_object().

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Public Member Functions
Static Public Member Functions
Public Attributes
Static Public Attributes
Protected Types
Protected Member Functions
Static Protected Attributes
Private Attributes
Detailed Description
Member Typedef Documentation
typedef std::map<std::string, std::pair<unsigned int, unsigned int> > ReferenceCounter::Counts [protected, inherited]Data structure to log the information. The log is identified by the class name.
Constructor & Destructor Documentation
DofObject::DofObject () [inline, protected]Constructor. Protected so that you can't instantiate one of these.
DofObject::DofObject (const DofObject &dof_obj)Copy-constructor.
DofObject::~DofObject () [inline, virtual]Destructor.
Member Function Documentation
void DofObject::add_system ()Adds an additional system to the DofObject
void DofObject::clear_dofs () [inline]Clear the DofMap data structures and return to a pristine state.
void DofObject::clear_old_dof_object ()Sets the old_dof_object to NULL
unsigned int DofObject::dof_number (const unsigned ints, const unsigned intvar, const unsigned intcomp) const [inline]Returns:
std::string ReferenceCounter::get_info () [static, inherited]Gets a string containing the reference information.
bool DofObject::has_dofs (const unsigned ints = libMesh::invalid_uint) const [inline]Returns:
unsigned int DofObject::id () const [inline]Returns:
void ReferenceCounter::increment_constructor_count (const std::string &name) [inline, protected, inherited]Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.
void ReferenceCounter::increment_destructor_count (const std::string &name) [inline, protected, inherited]Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.
void DofObject::invalidate () [inline]Invalidates all the indices for this DofObject
void DofObject::invalidate_dofs (const unsigned intsys_num = libMesh::invalid_uint) [inline]Sets all degree of freedom numbers to invalid_id
void DofObject::invalidate_id () [inline]Sets the id to invalid_id
void DofObject::invalidate_processor_id () [inline]Sets the processor id to invalid_processor_id
unsigned int DofObject::n_comp (const unsigned ints, const unsigned intvar) const [inline]Returns:
unsigned int DofObject::n_dofs (const unsigned ints, const unsigned intvar = libMesh::invalid_uint) const [inline]Returns:
static unsigned int ReferenceCounter::n_objects () [inline, static, inherited]Prints the number of outstanding (created, but not yet destroyed) objects.
unsigned int DofObject::n_systems () const [inline]Returns:
unsigned int DofObject::n_vars (const unsigned ints) const [inline]Returns:
virtual bool DofObject::operator== (const DofObject &) const [inline, virtual]Implemented in Elem and Node.
void ReferenceCounter::print_info () [static, inherited]Prints the reference information to std::cout.
void DofObject::processor_id (const unsigned intid) [inline]Sets the processor_id for this DofObject.
unsigned short int & DofObject::processor_id () [inline]Returns:
unsigned short int DofObject::processor_id () const [inline]Returns:
void DofObject::set_dof_number (const unsigned ints, const unsigned intvar, const unsigned intcomp, const unsigned intdn)Sets the global degree of freedom number variable var, component comp for system s associated with this DofObject
unsigned int & DofObject::set_id () [inline]Returns:
void DofObject::set_id (const unsigned intid) [inline]Sets the id for this DofObject
void DofObject::set_n_comp (const unsigned ints, const unsigned intvar, const unsigned intncomp)Sets the number of components for variable var of system s associated with this DofObject
void DofObject::set_n_systems (const unsigned ints)Sets the number of systems for this DofObject
void DofObject::set_n_vars (const unsigned ints, const unsigned intnvars)Sets number of variables associated with system s for this DofObject
void DofObject::set_old_dof_object ()Sets the old_dof_object to a copy of this
bool DofObject::valid_id () const [inline]Returns:
bool DofObject::valid_processor_id () const [inline]Returns:
Member Data Documentation
ReferenceCounter::Counts ReferenceCounter::_counts [static, protected, inherited]Actually holds the data.
unsigned int** DofObject::_dof_ids [private]The first global degree of freedom number for each variable of each system.
unsigned int DofObject::_id [private]The id of the DofObject
Threads::spin_mutex ReferenceCounter::_mutex [static, protected, inherited]Mutual exclusion object to enable thread-safe reference counting.
Threads::atomic< unsigned int > ReferenceCounter::_n_objects [static, protected, inherited]The number of objects. Print the reference count information when the number returns to 0.
unsigned char DofObject::_n_systems [private]The number of systems.
unsigned char** DofObject::_n_v_comp [private]The number of variables and components for each variable of each system associated with this DofObject. This is stored as an unsigned char for storage efficiency.
unsigned short int 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.
const unsigned int DofObject::invalid_id = libMesh::invalid_uint [static]An invaild id to distinguish an uninitialized DofObject
const unsigned short int DofObject::invalid_processor_id = static_cast<unsigned short int>(-1) [static]An invalid processor_id to distinguish DOFs that have not been assigned to a processor.
DofObject* DofObject::old_dof_objectThis object on the last mesh. Useful for projecting solutions from one mesh to another.
Author

This document was created by man2html, using the manual pages.
Time: 21:45:11 GMT, April 16, 2011