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 2119 of file system_projection.C.

References send_list.

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

Definition at line 2027 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.

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

Definition at line 2007 of file system_projection.C.

References libMesh::swap().

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

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