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

Constructor & Destructor Documentation

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

Definition at line 123 of file system_projection.C.

123  :
124  system(system_in),
125  send_list()
126  {}
std::vector< dof_id_type > send_list
libMesh::BuildProjectionList::BuildProjectionList ( BuildProjectionList other,
Threads::split   
)
inline

Definition at line 128 of file system_projection.C.

128  :
129  system(other.system),
130  send_list()
131  {}
std::vector< dof_id_type > send_list

Member Function Documentation

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

Definition at line 1167 of file system_projection.C.

References send_list.

1168 {
1169  // Joining simply requires I add the dof indices from the other object
1170  this->send_list.insert(this->send_list.end(),
1171  other.send_list.begin(),
1172  other.send_list.end());
1173 }
std::vector< dof_id_type > send_list
void libMesh::BuildProjectionList::operator() ( const ConstElemRange range)

Definition at line 1076 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::Elem::JUST_COARSENED, libMesh::Elem::JUST_REFINED, libMesh::DofObject::n_comp(), libMesh::DofObject::n_vars(), libMesh::Elem::node_ref_range(), libMesh::DofMap::old_dof_indices(), libMesh::DofObject::old_dof_object, libMesh::Elem::parent(), libMesh::Elem::refinement_flag(), and swap().

1077 {
1078  // The DofMap for this system
1079  const DofMap & dof_map = system.get_dof_map();
1080 
1081  const dof_id_type first_old_dof = dof_map.first_old_dof();
1082  const dof_id_type end_old_dof = dof_map.end_old_dof();
1083 
1084  // We can handle all the variables at once.
1085  // The old global DOF indices
1086  std::vector<dof_id_type> di;
1087 
1088  // Iterate over the elements in the range
1089  for (ConstElemRange::const_iterator elem_it=range.begin(); elem_it != range.end(); ++elem_it)
1090  {
1091  const Elem * elem = *elem_it;
1092  // If this element doesn't have an old_dof_object with dofs for the
1093  // current system, then it must be newly added, so the user
1094  // is responsible for setting the new dofs.
1095 
1096  // ... but we need a better way to test for that; the code
1097  // below breaks on any FE type for which the elem stores no
1098  // dofs.
1099  // if (!elem->old_dof_object || !elem->old_dof_object->has_dofs(system.number()))
1100  // continue;
1101 
1102  // Examining refinement flags instead should distinguish
1103  // between refinement-added and user-added elements lacking
1104  // old_dof_object
1105  if (!elem->old_dof_object &&
1106  elem->refinement_flag() != Elem::JUST_REFINED &&
1107  elem->refinement_flag() != Elem::JUST_COARSENED)
1108  continue;
1109 
1110  const Elem * parent = elem->parent();
1111 
1112  if (elem->refinement_flag() == Elem::JUST_REFINED)
1113  {
1114  libmesh_assert(parent);
1115 
1116  // We used to hack_p_level here, but that wasn't thread-safe
1117  // so now we take p refinement flags into account in
1118  // old_dof_indices
1119 
1120  dof_map.old_dof_indices (parent, di);
1121 
1122  for (auto & node : elem->node_ref_range())
1123  {
1124  const DofObject * old_dofs = node.old_dof_object;
1125 
1126  if (old_dofs)
1127  {
1128  const unsigned int sysnum = system.number();
1129  const unsigned int nv = old_dofs->n_vars(sysnum);
1130  for (unsigned int v=0; v != nv; ++v)
1131  {
1132  const unsigned int nc =
1133  old_dofs->n_comp(sysnum, v);
1134  for (unsigned int c=0; c != nc; ++c)
1135  di.push_back
1136  (old_dofs->dof_number(sysnum, v, c));
1137  }
1138  }
1139  }
1140 
1141  std::sort(di.begin(), di.end());
1142  std::vector<dof_id_type>::iterator new_end =
1143  std::unique(di.begin(), di.end());
1144  std::vector<dof_id_type>(di.begin(), new_end).swap(di);
1145  }
1146  else if (elem->refinement_flag() == Elem::JUST_COARSENED)
1147  {
1148  std::vector<dof_id_type> di_child;
1149  di.clear();
1150  for (auto & child : elem->child_ref_range())
1151  {
1152  dof_map.old_dof_indices (&child, di_child);
1153  di.insert(di.end(), di_child.begin(), di_child.end());
1154  }
1155  }
1156  else
1157  dof_map.old_dof_indices (elem, di);
1158 
1159  for (std::size_t i=0; i != di.size(); ++i)
1160  if (di[i] < first_old_dof || di[i] >= end_old_dof)
1161  this->send_list.push_back(di[i]);
1162  } // end elem loop
1163 }
const DofMap & get_dof_map() const
Definition: system.h:2030
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:2006
void swap(Iterator &lhs, Iterator &rhs)
uint8_t dof_id_type
Definition: id_types.h:64
void libMesh::BuildProjectionList::unique ( )

Definition at line 1056 of file system_projection.C.

References swap().

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

1057 {
1058  // Sort the send list. After this duplicated
1059  // elements will be adjacent in the vector
1060  std::sort(this->send_list.begin(),
1061  this->send_list.end());
1062 
1063  // Now use std::unique to remove duplicate entries
1064  std::vector<dof_id_type>::iterator new_end =
1065  std::unique (this->send_list.begin(),
1066  this->send_list.end());
1067 
1068  // Remove the end of the send_list. Use the "swap trick"
1069  // from Effective STL
1070  std::vector<dof_id_type>
1071  (this->send_list.begin(), new_end).swap (this->send_list);
1072 }
std::vector< dof_id_type > send_list
void swap(Iterator &lhs, Iterator &rhs)

Member Data Documentation

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

Definition at line 136 of file system_projection.C.

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

const System& libMesh::BuildProjectionList::system
private

Definition at line 120 of file system_projection.C.


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