libMesh
Public Member Functions | Public Attributes | Private Attributes | List of all members
libMesh::BuildProjectionList Class Reference

This class builds the send_list of old dof indices whose coefficients are needed to perform a projection. More...

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)

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   
)

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

References send_list.

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

Definition at line 2024 of file system_projection.C.

References libMesh::StoredRange< iterator_type, object_type >::begin(), libMesh::Elem::child_ref_range(), 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::DofObject::n_comp(), libMesh::DofObject::n_vars(), libMesh::Elem::node_ref_range(), 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.

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

Definition at line 2004 of file system_projection.C.

References libMesh::swap().

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

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