DofObject Class Reference

#include <dof_object.h>

Inheritance diagram for DofObject:

List of all members.

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

DofObjectold_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().

00312                       :
00313 #ifdef LIBMESH_ENABLE_AMR
00314   old_dof_object(NULL),
00315 #endif
00316   _id (invalid_id),
00317   _processor_id (invalid_processor_id),
00318   _n_systems  (0),
00319   _n_v_comp (NULL),
00320   _dof_ids (NULL)
00321 {
00322   this->invalidate();
00323 }

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().

00040                                               :
00041   ReferenceCountedObject<DofObject>(),
00042 #ifdef LIBMESH_ENABLE_AMR
00043   old_dof_object (NULL),
00044 #endif
00045   _id            (dof_obj._id),
00046   _processor_id  (dof_obj._processor_id),
00047   _n_systems     (dof_obj._n_systems),
00048   _n_v_comp      (NULL),
00049   _dof_ids       (NULL)
00050 {
00051 
00052   // Allocate storage for the dof numbers and copy
00053   // the values. 
00054   // IT IS UNDEFINED BEHAVIOR TO ALLOCATE AN ARRAY WITH ZERO ENTRIES,
00055   // IF n_systems==0, leave _n_v_comp, and _dof_ids NULL.
00056   if (this->n_systems() > 0)
00057     {
00058       _n_v_comp = new unsigned char* [this->n_systems()];
00059       _dof_ids  = new unsigned int*  [this->n_systems()];
00060 
00061       // gotta specifically NULL these - we rely later that
00062       // _n_v_comp[s] == NULL is synonymous with no variables in the system.
00063       for (unsigned int s=0; s<this->n_systems(); s++)
00064         {
00065           _n_v_comp[s] = NULL;
00066           _dof_ids[s]  = NULL;
00067         }      
00068     }
00069 
00070   // If n_systems==0, we don't enter this for loop.
00071   for (unsigned int s=0; s<this->n_systems(); s++)
00072     {
00073       // In case you have a system with no variables, it is undefined
00074       // behavior (UB) to allocate a zero-length array here.
00075       if (dof_obj.n_vars(s) > 0)
00076         {
00077           _n_v_comp[s] = new unsigned char [dof_obj.n_vars(s)+1]; 
00078           _dof_ids[s]  = new unsigned int  [dof_obj.n_vars(s)];
00079           
00080           _n_v_comp[s][0] = dof_obj.n_vars(s);
00081 
00082         }
00083       for (unsigned int v=0; v<this->n_vars(s); v++)
00084         {
00085           _n_v_comp[s][v+1]  = dof_obj.n_comp(s,v);
00086 
00087           if (this->n_comp(s,v) > 0)
00088             _dof_ids[s][v] = dof_obj.dof_number(s,v,0);
00089           else
00090             _dof_ids[s][v] = invalid_id;
00091         }
00092     }
00093 
00094   // Check that everything worked
00095 #ifdef DEBUG
00096 
00097   libmesh_assert (this->n_systems() == dof_obj.n_systems());
00098 
00099   for (unsigned int s=0; s<this->n_systems(); s++)
00100     {
00101       libmesh_assert (this->n_vars(s) == dof_obj.n_vars(s));
00102 
00103       for (unsigned int v=0; v<this->n_vars(s); v++)
00104         {
00105           libmesh_assert (this->n_comp(s,v) == dof_obj.n_comp(s,v));
00106 
00107           for (unsigned int c=0; c<this->n_comp(s,v); c++)
00108             libmesh_assert (this->dof_number(s,v,c) == dof_obj.dof_number(s,v,c));
00109         }
00110     }
00111   
00112 #endif
00113 }

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

Destructor.

Definition at line 330 of file dof_object.h.

References clear_dofs(), and clear_old_dof_object().

00331 {
00332   // Free all memory.
00333 #ifdef LIBMESH_ENABLE_AMR
00334   this->clear_old_dof_object ();
00335 #endif
00336   this->clear_dofs ();
00337 }


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().

00189 {
00190   if (this->n_systems() > 0)
00191     {
00192       // Copy the old systems to temporary storage
00193       unsigned char **old_n_v_comp = new unsigned char* [this->n_systems()];
00194       unsigned int  **old_dof_ids  = new unsigned int*  [this->n_systems()]; 
00195       
00196       for (unsigned int s=0; s<this->n_systems(); s++)
00197         {
00198           old_n_v_comp[s] = _n_v_comp[s];
00199           old_dof_ids[s]  = _dof_ids[s];
00200         }
00201       
00202       // Delete old storage
00203       libmesh_assert (_n_v_comp != NULL); delete [] _n_v_comp; _n_v_comp = NULL;
00204       libmesh_assert (_dof_ids  != NULL); delete [] _dof_ids;  _dof_ids  = NULL;
00205   
00206       // Allocate space for new system
00207       _n_v_comp= new unsigned char* [this->n_systems()+1];
00208       _dof_ids = new unsigned int*  [this->n_systems()+1];
00209       
00210       // Copy the other systems
00211       for (unsigned int s=0; s<this->n_systems(); s++)
00212         {
00213           _n_v_comp[s] = old_n_v_comp[s];
00214           _dof_ids[s]  = old_dof_ids[s];
00215         }
00216                
00217       // Delete temporary storage
00218       libmesh_assert (old_n_v_comp != NULL); delete [] old_n_v_comp; old_n_v_comp = NULL;
00219       libmesh_assert (old_dof_ids  != NULL); delete [] old_dof_ids;  old_dof_ids  = NULL;
00220     }
00221   else
00222     {
00223       libmesh_assert (_n_v_comp == NULL);
00224       libmesh_assert (_dof_ids  == NULL);
00225       
00226       // Allocate space for new system
00227       _n_v_comp = new unsigned char* [this->n_systems()+1];
00228       _dof_ids  = new unsigned int*  [this->n_systems()+1];      
00229     }
00230   
00231   // Initialize the new system
00232   _n_v_comp[this->n_systems()] = NULL;
00233   _dof_ids[this->n_systems()]  = NULL;
00234   
00235   // Done. Don't forget to increment the number of systems!
00236   _n_systems++;
00237 }

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().

00389 {
00390   // Only clear if there is data
00391   if (this->n_systems() != 0)
00392     {
00393       libmesh_assert (_n_v_comp != NULL);
00394       libmesh_assert (_dof_ids  != NULL);
00395       
00396       for (unsigned int s=0; s<this->n_systems(); s++)
00397         {
00398           if (_dof_ids[s] != NULL) // This has only been allocated if 
00399             {                      // variables were declared
00400               delete [] _dof_ids[s]; _dof_ids[s] = NULL;
00401             }
00402           
00403           if (_n_v_comp[s] != NULL) // it is possible the number of variables is 0,
00404             {                       // but this was allocated (_n_v_comp[s][0] == 0)
00405               delete [] _n_v_comp[s]; _n_v_comp[s] = NULL;
00406             }
00407         }
00408       
00409       delete [] _n_v_comp; _n_v_comp = NULL;
00410       delete [] _dof_ids;  _dof_ids  = NULL;
00411     }
00412   
00413   // Make sure we cleaned up
00414   // (or there was nothing there)
00415   libmesh_assert (_n_v_comp == NULL);
00416   libmesh_assert (_dof_ids  == NULL);
00417   
00418   // No systems now.
00419   _n_systems = 0;
00420 }

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().

00121 {
00122   // If we have been called before...
00123   // prevent a memory leak
00124   if (old_dof_object != NULL)
00125     {
00126       delete this->old_dof_object;
00127       this->old_dof_object = NULL;
00128     }  
00129 }

unsigned int DofObject::dof_number ( const unsigned int  s,
const unsigned int  var,
const unsigned int  comp 
) 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(), 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().

00567 {
00568   libmesh_assert (s < this->n_systems());
00569   libmesh_assert (var  < this->n_vars(s));
00570   libmesh_assert (_dof_ids != NULL);
00571   libmesh_assert (_dof_ids[s] != NULL);  
00572   libmesh_assert (comp < this->n_comp(s,var));
00573   
00574   if (_dof_ids[s][var] == invalid_id)
00575     return invalid_id;
00576   else
00577     return (_dof_ids[s][var] + comp);
00578 }

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 QuadratureRules::name().

Referenced by ReferenceCounter::print_info().

00046 {
00047 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
00048 
00049   std::ostringstream out;
00050   
00051   out << '\n'
00052       << " ---------------------------------------------------------------------------- \n"
00053       << "| Reference count information                                                |\n"
00054       << " ---------------------------------------------------------------------------- \n";
00055   
00056   for (Counts::iterator it = _counts.begin();
00057        it != _counts.end(); ++it)
00058     {
00059       const std::string name(it->first);
00060       const unsigned int creations    = it->second.first;
00061       const unsigned int destructions = it->second.second;
00062 
00063       out << "| " << name << " reference count information:\n"
00064           << "|  Creations:    " << creations    << '\n'
00065           << "|  Destructions: " << destructions << '\n';
00066     }
00067   
00068   out << " ---------------------------------------------------------------------------- \n";
00069 
00070   return out.str();
00071 
00072 #else
00073 
00074   return "";
00075   
00076 #endif
00077 }

bool 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 583 of file dof_object.h.

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

Referenced by DofMap::reinit().

00584 {
00585   if (sys == libMesh::invalid_uint)
00586     {
00587       for (unsigned int s=0; s<this->n_systems(); s++)
00588         if (this->n_vars(s))
00589           return true;
00590     }
00591   
00592   else
00593     {
00594       libmesh_assert (sys < this->n_systems());
00595 
00596       if (this->n_vars(sys))
00597         return true;
00598     }
00599   
00600   return false;
00601 }

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(), 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(), clough_compute_coefs(), 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(), hermite_compute_coefs(), 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(), Elem::node(), MeshData::node_to_foreign_id(), VTKIO::nodes_to_vtk(), PatchRecoveryErrorEstimator::EstimateError::operator()(), XdrIO::pack_element(), ErrorVector::plot_error(), Nemesis_IO::read(), ExodusII_IO::read(), ParallelMesh::renumber_elem(), ParallelMesh::renumber_node(), ParallelMesh::renumber_nodes_and_elements(), HPCoarsenTest::select_refinement(), 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().

00450 {
00451   libmesh_assert (this->valid_id());
00452   return _id;
00453 }

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, and Threads::spin_mtx.

Referenced by ReferenceCountedObject< SparseMatrix< T > >::ReferenceCountedObject().

00150 {
00151   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00152   std::pair<unsigned int, unsigned int>& p = _counts[name];
00153 
00154   p.first++;
00155 }

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, and Threads::spin_mtx.

Referenced by ReferenceCountedObject< SparseMatrix< T > >::~ReferenceCountedObject().

00168 {
00169   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00170   std::pair<unsigned int, unsigned int>& p = _counts[name];
00171 
00172   p.second++;
00173 }

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().

00379 {
00380   this->invalidate_dofs ();
00381   this->invalidate_id ();
00382   this->invalidate_processor_id ();
00383 }

void DofObject::invalidate_dofs ( const unsigned int  sys_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().

00343 {
00344   // If the user does not specify the system number...
00345   if (sys_num >= this->n_systems()) 
00346     {
00347       for (unsigned int s=0; s<this->n_systems(); s++)
00348         for (unsigned int v=0; v<this->n_vars(s); v++)
00349           if (this->n_comp(s,v))
00350             this->set_dof_number(s,v,0,invalid_id);
00351     }
00352   // ...otherwise invalidate the dofs for all systems
00353   else
00354     for (unsigned int v=0; v<n_vars(sys_num); v++)
00355       if (this->n_comp(sys_num,v))
00356         this->set_dof_number(sys_num,v,0,invalid_id);
00357 }

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().

00363 {
00364   this->set_id (invalid_id);
00365 }

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().

00371 {
00372   this->processor_id (invalid_processor_id);
00373 }

unsigned int 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 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().

00540 {
00541   libmesh_assert (s < this->n_systems());
00542   libmesh_assert (_dof_ids != NULL);
00543   libmesh_assert (_dof_ids[s] != NULL);
00544   libmesh_assert (_n_v_comp != NULL);
00545   libmesh_assert (_n_v_comp[s] != NULL);
00546 
00547 # ifdef DEBUG
00548   // Does this ever happen?  I doubt it... 3/7/2003 (BSK)
00549   if (var >= this->n_vars(s))
00550     {
00551       std::cout << "s=" << s << ", var=" << var << std::endl
00552                 << "this->n_vars(s)=" << this->n_vars(s) << std::endl
00553                 << "this->n_systems()=" << this->n_systems() << std::endl;
00554       libmesh_error();
00555     }
00556 # endif
00557   
00558   return static_cast<unsigned int>(_n_v_comp[s][var+1]);
00559 }

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

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

00427 {
00428   libmesh_assert (s < this->n_systems());
00429   
00430   unsigned int num = 0;
00431 
00432   // Count all variables
00433   if (var == libMesh::invalid_uint)
00434     for (unsigned int v=0; v<this->n_vars(s); v++)
00435       num += this->n_comp(s,v);
00436   
00437   // Only count specified variable
00438   else
00439     {
00440       num = this->n_comp(s,var);
00441     }
00442 
00443   return num;
00444 }

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.

00077   { 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().

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

unsigned int DofObject::n_vars ( const unsigned int  s  )  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().

00526 {
00527   libmesh_assert (s < this->n_systems());
00528   libmesh_assert (_n_v_comp != NULL);
00529   if (_n_v_comp[s] == NULL)
00530     return 0;
00531   return static_cast<unsigned int>(_n_v_comp[s][0]);
00532 }

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.

00251   { 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().

00084 {
00085 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
00086   
00087   std::cout << ReferenceCounter::get_info();
00088   
00089 #endif
00090 }

void DofObject::processor_id ( const unsigned int  id  )  [inline]

Sets the processor_id for this DofObject.

Definition at line 489 of file dof_object.h.

References processor_id().

00490 {
00491 #ifdef DEBUG
00492   
00493   if (id != static_cast<unsigned int>(static_cast<unsigned short int>(id)))
00494     {
00495       std::cerr << "ERROR: id too large for unsigned short int!" << std::endl
00496                 << "Recompile with DofObject::_processor_id larger!" << std::endl;
00497       
00498       libmesh_error();
00499     }
00500 
00501 #endif
00502   
00503   this->processor_id() = id;
00504 }

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.

00482 {
00483   return _processor_id;
00484 }

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 MetisPartitioner::_do_partition(), LinearPartitioner::_do_partition(), CentroidPartitioner::_do_partition(), 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().

00474 {
00475   return _processor_id;
00476 }

void DofObject::set_dof_number ( const unsigned int  s,
const unsigned int  var,
const unsigned int  comp,
const unsigned int  dn 
)

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().

00342 {
00343   libmesh_assert (s < this->n_systems());
00344   libmesh_assert (var  < this->n_vars(s));
00345   libmesh_assert (_dof_ids != NULL);
00346   libmesh_assert (_dof_ids[s] != NULL);
00347   libmesh_assert (comp < this->n_comp(s,var));
00348   
00349   //We intend to change all dof numbers together or not at all
00350   if (comp)
00351     libmesh_assert ((dn == invalid_id && _dof_ids[s][var] == invalid_id) || 
00352                     (dn == _dof_ids[s][var] + comp));
00353   else
00354     _dof_ids[s][var] = dn;
00355 
00356 
00357   libmesh_assert(this->dof_number(s, var, comp) == dn);
00358 }

void DofObject::set_id ( const unsigned int  id  )  [inline]

Sets the id for this DofObject

Definition at line 143 of file dof_object.h.

References set_id().

Referenced by set_id().

00144   { this->set_id() = id; }

void 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 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().

00301 {
00302   libmesh_assert (s < this->n_systems());
00303   libmesh_assert (var < this->n_vars(s));
00304   libmesh_assert (_dof_ids != NULL);
00305   libmesh_assert (_dof_ids[s] != NULL);
00306   
00307   // Check for trivial return
00308   if (ncomp == this->n_comp(s,var)) return;
00309 
00310 #ifdef DEBUG
00311 
00312   if (ncomp != static_cast<unsigned int>(static_cast<unsigned char>(ncomp)))
00313     {
00314       std::cerr << "Unsigned char not big enough to hold ncomp!" << std::endl
00315                 << "Recompile with _n_v_comp set to a bigger type!"
00316                 << std::endl;
00317       
00318       libmesh_error();
00319     }
00320   
00321 #endif
00322 
00323   // We use (invalid_id - 1) to signify no
00324   // components for this object
00325   if (ncomp == 0)
00326     {
00327       _dof_ids[s][var] = (invalid_id - 1);
00328     }
00329   
00330   libmesh_assert (_n_v_comp    != NULL);
00331   libmesh_assert (_n_v_comp[s] != NULL);
00332     
00333   _n_v_comp[s][var+1]  = static_cast<unsigned char>(ncomp);
00334 }

void DofObject::set_n_systems ( const unsigned int  s  ) 

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().

00149 {
00150   // Check for trivial return
00151   if (ns == this->n_systems()) return;
00152  
00153 #ifdef DEBUG
00154 
00155   if (ns != static_cast<unsigned int>(static_cast<unsigned char>(ns)))
00156     {
00157       std::cerr << "Unsigned char not big enough to hold ns!" << std::endl
00158                 << "Recompile with _n_systems set to a bigger type!"
00159                 << std::endl;
00160       
00161       libmesh_error();
00162     }
00163                                         
00164 #endif
00165 
00166 
00167   // Clear any existing data.  This is safe to call
00168   // even if we don't have any data.
00169   this->clear_dofs();
00170 
00171   // Set the new number of systems
00172   _n_systems = static_cast<unsigned char>(ns);
00173   
00174   // Allocate storage for the systems
00175   _n_v_comp = new unsigned char* [this->n_systems()];
00176   _dof_ids  = new unsigned int*  [this->n_systems()];
00177 
00178   // No variables have been declared yet.
00179   for (unsigned int s=0; s<this->n_systems(); s++)
00180     {
00181       _n_v_comp[s] = NULL;
00182       _dof_ids[s]  = NULL;
00183     }
00184 }

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

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().

00243 {
00244   libmesh_assert (s < this->n_systems());
00245   libmesh_assert (_n_v_comp != NULL);
00246   libmesh_assert (_dof_ids  != NULL);
00247 
00248 #ifdef DEBUG
00249 
00250   if (nvars != static_cast<unsigned int>(static_cast<unsigned char>(nvars)))
00251     {
00252       std::cerr << "Unsigned char not big enough to hold nvar!" << std::endl
00253                 << "Recompile with _n_vars set to a bigger type!"
00254                 << std::endl;
00255       
00256       libmesh_error();
00257     }
00258                                         
00259 #endif
00260 
00261   
00262   
00263   // If we already have memory allocated clear it.
00264   if (this->n_vars(s) != 0)
00265     {
00266       libmesh_assert (_n_v_comp[s] != NULL); delete [] _n_v_comp[s]; _n_v_comp[s] = NULL;
00267       libmesh_assert (_dof_ids[s]  != NULL); delete [] _dof_ids[s];  _dof_ids[s]  = NULL;
00268     }
00269 
00270   // Reset the number of variables in the system  
00271   if (nvars > 0)
00272     {
00273       libmesh_assert (_n_v_comp[s] == NULL);
00274       libmesh_assert (_dof_ids[s]  == NULL);
00275       
00276       _n_v_comp[s] = new unsigned char [nvars+1];
00277       _dof_ids[s]  = new unsigned int  [nvars];
00278       
00279       _n_v_comp[s][0] = static_cast<unsigned char>(nvars);
00280 
00281       libmesh_assert (nvars == this->n_vars(s));
00282       
00283       for (unsigned int v=0; v<this->n_vars(s); v++)
00284         {
00285           _n_v_comp[s][v+1] = 0;
00286           _dof_ids[s][v]    = invalid_id - 1;
00287         }
00288     }
00289   else // (nvars == 0)
00290     {
00291       libmesh_assert (_n_v_comp[s] == NULL);
00292       libmesh_assert (_dof_ids[s]  == NULL);
00293     }
00294 }

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().

00134 {
00135   this->clear_old_dof_object();
00136 
00137   libmesh_assert (this->old_dof_object == NULL);
00138   
00139   // Make a new DofObject, assign a copy of \p this.
00140   // Make sure the copy ctor for DofObject works!!
00141   this->old_dof_object = new DofObject(*this);
00142 }

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().

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

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.

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


Member Data Documentation

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().

This 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().


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

Site Created By: libMesh Developers
Last modified: November 25 2009 03:44:06.

Hosted By:
SourceForge.net Logo