libMesh::BuildProjectionList Class Reference

Public Member Functions

 BuildProjectionList (const System &system_in)
 
 BuildProjectionList (BuildProjectionList &other, Threads::split)
 
void unique ()
 
void operator() (const ConstElemRange &range)
 
void join (const BuildProjectionList &other)
 

Public Attributes

std::vector< dof_id_typesend_list
 

Private Attributes

const Systemsystem
 

Detailed Description

This class builds the send_list of old dof indices whose coefficients are needed to perform a projection. This may be executed in parallel on multiple threads. The end result is a send_list vector which is unsorted and may contain duplicate elements. The unique() method can be used to sort and create a unique list.

Definition at line 491 of file system_projection.C.

Constructor & Destructor Documentation

libMesh::BuildProjectionList::BuildProjectionList ( const System system_in)
inline

Definition at line 497 of file system_projection.C.

497  :
498  system(system_in),
499  send_list()
500  {}
std::vector< dof_id_type > send_list
libMesh::BuildProjectionList::BuildProjectionList ( BuildProjectionList other,
Threads::split   
)
inline

Definition at line 502 of file system_projection.C.

References libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::operator()().

502  :
503  system(other.system),
504  send_list()
505  {}
std::vector< dof_id_type > send_list

Member Function Documentation

void libMesh::BuildProjectionList::join ( const BuildProjectionList other)

Definition at line 2117 of file system_projection.C.

References send_list.

2118 {
2119  // Joining simply requires I add the dof indices from the other object
2120  this->send_list.insert(this->send_list.end(),
2121  other.send_list.begin(),
2122  other.send_list.end());
2123 }
std::vector< dof_id_type > send_list
void libMesh::BuildProjectionList::operator() ( const ConstElemRange range)

Definition at line 2025 of file system_projection.C.

References libMesh::StoredRange< iterator_type, object_type >::begin(), libMesh::Elem::child_ptr(), libMesh::DofObject::dof_number(), libMesh::StoredRange< iterator_type, object_type >::end(), libMesh::DofMap::end_old_dof(), libMesh::DofMap::first_old_dof(), libMesh::System::get_dof_map(), libMesh::Elem::JUST_COARSENED, libMesh::Elem::JUST_REFINED, libMesh::libmesh_assert(), libMesh::Elem::n_children(), libMesh::DofObject::n_comp(), libMesh::Elem::n_nodes(), libMesh::DofObject::n_vars(), libMesh::Elem::node_ptr(), libMesh::System::number(), libMesh::DofMap::old_dof_indices(), libMesh::DofObject::old_dof_object, libMesh::Elem::parent(), libMesh::Elem::refinement_flag(), libMesh::swap(), and libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::system.

2026 {
2027  // The DofMap for this system
2028  const DofMap & dof_map = system.get_dof_map();
2029 
2030  const dof_id_type first_old_dof = dof_map.first_old_dof();
2031  const dof_id_type end_old_dof = dof_map.end_old_dof();
2032 
2033  // We can handle all the variables at once.
2034  // The old global DOF indices
2035  std::vector<dof_id_type> di;
2036 
2037  // Iterate over the elements in the range
2038  for (ConstElemRange::const_iterator elem_it=range.begin(); elem_it != range.end(); ++elem_it)
2039  {
2040  const Elem * elem = *elem_it;
2041  // If this element doesn't have an old_dof_object with dofs for the
2042  // current system, then it must be newly added, so the user
2043  // is responsible for setting the new dofs.
2044 
2045  // ... but we need a better way to test for that; the code
2046  // below breaks on any FE type for which the elem stores no
2047  // dofs.
2048  // if (!elem->old_dof_object || !elem->old_dof_object->has_dofs(system.number()))
2049  // continue;
2050 
2051  // Examining refinement flags instead should distinguish
2052  // between refinement-added and user-added elements lacking
2053  // old_dof_object
2054  if (!elem->old_dof_object &&
2055  elem->refinement_flag() != Elem::JUST_REFINED &&
2056  elem->refinement_flag() != Elem::JUST_COARSENED)
2057  continue;
2058 
2059  const Elem * parent = elem->parent();
2060 
2061  if (elem->refinement_flag() == Elem::JUST_REFINED)
2062  {
2063  libmesh_assert(parent);
2064 
2065  // We used to hack_p_level here, but that wasn't thread-safe
2066  // so now we take p refinement flags into account in
2067  // old_dof_indices
2068 
2069  dof_map.old_dof_indices (parent, di);
2070 
2071  for (unsigned int n=0; n != elem->n_nodes(); ++n)
2072  {
2073  const Node * node = elem->node_ptr(n);
2074  const DofObject * old_dofs = node->old_dof_object;
2075 
2076  if (old_dofs)
2077  {
2078  const unsigned int sysnum = system.number();
2079  const unsigned int nv = old_dofs->n_vars(sysnum);
2080  for (unsigned int v=0; v != nv; ++v)
2081  {
2082  const unsigned int nc =
2083  old_dofs->n_comp(sysnum, v);
2084  for (unsigned int c=0; c != nc; ++c)
2085  di.push_back
2086  (old_dofs->dof_number(sysnum, v, c));
2087  }
2088  }
2089  }
2090 
2091  std::sort(di.begin(), di.end());
2092  std::vector<dof_id_type>::iterator new_end =
2093  std::unique(di.begin(), di.end());
2094  std::vector<dof_id_type>(di.begin(), new_end).swap(di);
2095  }
2096  else if (elem->refinement_flag() == Elem::JUST_COARSENED)
2097  {
2098  std::vector<dof_id_type> di_child;
2099  di.clear();
2100  for (unsigned int c=0; c != elem->n_children(); ++c)
2101  {
2102  dof_map.old_dof_indices (elem->child_ptr(c), di_child);
2103  di.insert(di.end(), di_child.begin(), di_child.end());
2104  }
2105  }
2106  else
2107  dof_map.old_dof_indices (elem, di);
2108 
2109  for (std::size_t i=0; i != di.size(); ++i)
2110  if (di[i] < first_old_dof || di[i] >= end_old_dof)
2111  this->send_list.push_back(di[i]);
2112  } // end elem loop
2113 }
libmesh_assert(j)
const DofMap & get_dof_map() const
Definition: system.h:2028
std::vector< object_type >::const_iterator const_iterator
Definition: stored_range.h:58
std::vector< dof_id_type > send_list
unsigned int number() const
Definition: system.h:2004
X_input swap(X_system)
uint8_t dof_id_type
Definition: id_types.h:64
void libMesh::BuildProjectionList::unique ( )

Definition at line 2005 of file system_projection.C.

References libMesh::swap().

Referenced by libMesh::System::project_vector().

2006 {
2007  // Sort the send list. After this duplicated
2008  // elements will be adjacent in the vector
2009  std::sort(this->send_list.begin(),
2010  this->send_list.end());
2011 
2012  // Now use std::unique to remove duplicate entries
2013  std::vector<dof_id_type>::iterator new_end =
2014  std::unique (this->send_list.begin(),
2015  this->send_list.end());
2016 
2017  // Remove the end of the send_list. Use the "swap trick"
2018  // from Effective STL
2019  std::vector<dof_id_type>
2020  (this->send_list.begin(), new_end).swap (this->send_list);
2021 }
std::vector< dof_id_type > send_list
X_input swap(X_system)

Member Data Documentation

std::vector<dof_id_type> libMesh::BuildProjectionList::send_list

Definition at line 510 of file system_projection.C.

Referenced by join(), and libMesh::System::project_vector().

const System& libMesh::BuildProjectionList::system
private

Definition at line 494 of file system_projection.C.


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