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

Constructor & Destructor Documentation

◆ BuildProjectionList() [1/2]

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

Definition at line 133 of file system_projection.C.

133  :
134  system(system_in),
135  send_list()
136  {}
std::vector< dof_id_type > send_list

◆ BuildProjectionList() [2/2]

libMesh::BuildProjectionList::BuildProjectionList ( BuildProjectionList other,
Threads::split   
)
inline

Definition at line 138 of file system_projection.C.

138  :
139  system(other.system),
140  send_list()
141  {}
std::vector< dof_id_type > send_list

Member Function Documentation

◆ join()

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

Definition at line 1171 of file system_projection.C.

References send_list.

1172 {
1173  // Joining simply requires I add the dof indices from the other object
1174  this->send_list.insert(this->send_list.end(),
1175  other.send_list.begin(),
1176  other.send_list.end());
1177 }
std::vector< dof_id_type > send_list

◆ operator()()

void libMesh::BuildProjectionList::operator() ( const ConstElemRange range)

Definition at line 1075 of file system_projection.C.

References libMesh::DofObject::dof_number(), libMesh::DofMap::end_old_dof(), libMesh::DofMap::first_old_dof(), libMesh::DofObject::n_comp_group(), libMesh::DofObject::n_var_groups(), libMesh::DofObject::n_vars(), libMesh::DofMap::old_dof_indices(), libMesh::DofObject::old_dof_object, libMesh::Elem::parent(), and swap().

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

◆ unique()

void libMesh::BuildProjectionList::unique ( )

Definition at line 1055 of file system_projection.C.

References swap().

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

Member Data Documentation

◆ send_list

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

Definition at line 146 of file system_projection.C.

Referenced by join().

◆ system

const System& libMesh::BuildProjectionList::system
private

Definition at line 130 of file system_projection.C.


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