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

Constructor & Destructor Documentation

◆ BuildProjectionList() [1/2]

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

Definition at line 173 of file system_projection.C.

173  :
174  system(system_in),
175  send_list()
176  {}

◆ BuildProjectionList() [2/2]

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

Definition at line 178 of file system_projection.C.

178  :
179  system(other.system),
180  send_list()
181  {}

Member Function Documentation

◆ join()

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

Definition at line 1314 of file system_projection.C.

1315 {
1316  // Joining simply requires I add the dof indices from the other object
1317  this->send_list.insert(this->send_list.end(),
1318  other.send_list.begin(),
1319  other.send_list.end());
1320 }

References send_list.

◆ operator()()

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

Definition at line 1218 of file system_projection.C.

1219 {
1220  // The DofMap for this system
1221  const DofMap & dof_map = system.get_dof_map();
1222 
1223  const dof_id_type first_old_dof = dof_map.first_old_dof();
1224  const dof_id_type end_old_dof = dof_map.end_old_dof();
1225 
1226  // We can handle all the variables at once.
1227  // The old global DOF indices
1228  std::vector<dof_id_type> di;
1229 
1230  // Iterate over the elements in the range
1231  for (const auto & elem : range)
1232  {
1233  // If this element doesn't have an old_dof_object with dofs for the
1234  // current system, then it must be newly added, so the user
1235  // is responsible for setting the new dofs.
1236 
1237  // ... but we need a better way to test for that; the code
1238  // below breaks on any FE type for which the elem stores no
1239  // dofs.
1240  // if (!elem->old_dof_object || !elem->old_dof_object->has_dofs(system.number()))
1241  // continue;
1242 
1243  // Examining refinement flags instead should distinguish
1244  // between refinement-added and user-added elements lacking
1245  // old_dof_object
1246  if (!elem->old_dof_object &&
1247  elem->refinement_flag() != Elem::JUST_REFINED &&
1248  elem->refinement_flag() != Elem::JUST_COARSENED)
1249  continue;
1250 
1251  const Elem * parent = elem->parent();
1252 
1253  if (elem->refinement_flag() == Elem::JUST_REFINED)
1254  {
1255  libmesh_assert(parent);
1256 
1257  // We used to hack_p_level here, but that wasn't thread-safe
1258  // so now we take p refinement flags into account in
1259  // old_dof_indices
1260 
1261  dof_map.old_dof_indices (parent, di);
1262 
1263  for (auto & node : elem->node_ref_range())
1264  {
1265  const DofObject * old_dofs = node.old_dof_object;
1266 
1267  if (old_dofs)
1268  {
1269  const unsigned int sysnum = system.number();
1270  const unsigned int nvg = old_dofs->n_var_groups(sysnum);
1271 
1272  for (unsigned int vg=0; vg != nvg; ++vg)
1273  {
1274  const unsigned int nvig =
1275  old_dofs->n_vars(sysnum, vg);
1276  for (unsigned int vig=0; vig != nvig; ++vig)
1277  {
1278  const unsigned int n_comp =
1279  old_dofs->n_comp_group(sysnum, vg);
1280  for (unsigned int c=0; c != n_comp; ++c)
1281  di.push_back
1282  (old_dofs->dof_number(sysnum, vg, vig, c, n_comp));
1283  }
1284  }
1285  }
1286  }
1287 
1288  std::sort(di.begin(), di.end());
1289  std::vector<dof_id_type>::iterator new_end =
1290  std::unique(di.begin(), di.end());
1291  std::vector<dof_id_type>(di.begin(), new_end).swap(di);
1292  }
1293  else if (elem->refinement_flag() == Elem::JUST_COARSENED)
1294  {
1295  std::vector<dof_id_type> di_child;
1296  di.clear();
1297  for (auto & child : elem->child_ref_range())
1298  {
1299  dof_map.old_dof_indices (&child, di_child);
1300  di.insert(di.end(), di_child.begin(), di_child.end());
1301  }
1302  }
1303  else
1304  dof_map.old_dof_indices (elem, di);
1305 
1306  for (auto di_i : di)
1307  if (di_i < first_old_dof || di_i >= end_old_dof)
1308  this->send_list.push_back(di_i);
1309  } // end elem loop
1310 }

References libMesh::DofObject::dof_number(), libMesh::DofMap::end_old_dof(), libMesh::DofMap::first_old_dof(), libMesh::libmesh_assert(), 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().

◆ unique()

void libMesh::BuildProjectionList::unique ( )

Definition at line 1198 of file system_projection.C.

1199 {
1200  // Sort the send list. After this duplicated
1201  // elements will be adjacent in the vector
1202  std::sort(this->send_list.begin(),
1203  this->send_list.end());
1204 
1205  // Now use std::unique to remove duplicate entries
1206  std::vector<dof_id_type>::iterator new_end =
1207  std::unique (this->send_list.begin(),
1208  this->send_list.end());
1209 
1210  // Remove the end of the send_list. Use the "swap trick"
1211  // from Effective STL
1212  std::vector<dof_id_type>
1213  (this->send_list.begin(), new_end).swap (this->send_list);
1214 }

References swap().

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

Member Data Documentation

◆ send_list

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

Definition at line 186 of file system_projection.C.

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

◆ system

const System& libMesh::BuildProjectionList::system
private

Definition at line 170 of file system_projection.C.


The documentation for this class was generated from the following file:
libMesh::dof_id_type
uint8_t dof_id_type
Definition: id_types.h:67
libMesh::Elem::JUST_REFINED
Definition: elem.h:1172
libMesh::System::number
unsigned int number() const
Definition: system.h:2075
libMesh::libmesh_assert
libmesh_assert(ctx)
libMesh::Elem::JUST_COARSENED
Definition: elem.h:1173
libMesh::BuildProjectionList::send_list
std::vector< dof_id_type > send_list
Definition: system_projection.C:186
swap
void swap(Iterator &lhs, Iterator &rhs)
swap, used to implement op=
Definition: variant_filter_iterator.h:478
libMesh::BuildProjectionList::system
const System & system
Definition: system_projection.C:170
libMesh::System::get_dof_map
const DofMap & get_dof_map() const
Definition: system.h:2099