libMesh
Loading...
Searching...
No Matches
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_type > send_list
 

Private Attributes

const System & system
 

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

Constructor & Destructor Documentation

◆ BuildProjectionList() [1/2]

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

Definition at line 169 of file system_projection.C.

169 :
170 system(system_in),
171 send_list()
172 {}
std::vector< dof_id_type > send_list

◆ BuildProjectionList() [2/2]

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

Definition at line 174 of file system_projection.C.

174 :
175 system(other.system),
176 send_list()
177 {}

Member Function Documentation

◆ join()

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

Definition at line 1513 of file system_projection.C.

1514{
1515 // Joining simply requires I add the dof indices from the other object
1516 this->send_list.insert(this->send_list.end(),
1517 other.send_list.begin(),
1518 other.send_list.end());
1519}

References send_list.

◆ operator()()

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

Definition at line 1396 of file system_projection.C.

1397{
1398 // The DofMap for this system
1399 const DofMap & dof_map = system.get_dof_map();
1400
1401 const dof_id_type first_old_dof = dof_map.first_old_dof();
1402 const dof_id_type end_old_dof = dof_map.end_old_dof();
1403
1404 // We can handle all the variables at once.
1405 // The old global DOF indices
1406 std::vector<dof_id_type> di;
1407
1408 // Iterate over the elements in the range
1409 for (const auto & elem : range)
1410 {
1411 // If this element doesn't have an old_dof_object with dofs for the
1412 // current system, then it must be newly added, so the user
1413 // is responsible for setting the new dofs.
1414
1415 // ... but we need a better way to test for that; the code
1416 // below breaks on any FE type for which the elem stores no
1417 // dofs.
1418 // if (!elem->get_old_dof_object() || !elem->get_old_dof_object()->has_dofs(system.number()))
1419 // continue;
1420
1421 // Examining refinement flags instead should distinguish
1422 // between refinement-added and user-added elements lacking
1423 // old_dof_object
1424 const DofObject * old_dof_object = elem->get_old_dof_object();
1425 if (!old_dof_object &&
1426 elem->refinement_flag() != Elem::JUST_REFINED &&
1427 elem->refinement_flag() != Elem::JUST_COARSENED)
1428 continue;
1429
1430 const Elem * parent = elem->parent();
1431
1432 if (elem->refinement_flag() == Elem::JUST_REFINED)
1433 {
1434 libmesh_assert(parent);
1435
1436 // We used to hack_p_level here, but that wasn't thread-safe
1437 // so now we take p refinement flags into account in
1438 // old_dof_indices
1439
1440 dof_map.old_dof_indices (parent, di);
1441
1442 for (auto & node : elem->node_ref_range())
1443 {
1444 const DofObject * old_dofs = node.get_old_dof_object();
1445
1446 if (old_dofs)
1447 {
1448 const unsigned int sysnum = system.number();
1449 const unsigned int nvg = old_dofs->n_var_groups(sysnum);
1450
1451 for (unsigned int vg=0; vg != nvg; ++vg)
1452 {
1453 const unsigned int nvig =
1454 old_dofs->n_vars(sysnum, vg);
1455 for (unsigned int vig=0; vig != nvig; ++vig)
1456 {
1457 const unsigned int n_comp =
1458 old_dofs->n_comp_group(sysnum, vg);
1459 for (unsigned int c=0; c != n_comp; ++c)
1460 {
1461 const dof_id_type old_id =
1462 old_dofs->dof_number(sysnum, vg, vig,
1463 c, n_comp);
1464
1465 // We should either have no old id
1466 // (e.g. on a newly expanded subdomain)
1467 // or an id from the old system.
1468 libmesh_assert(old_id < dof_map.n_old_dofs() ||
1469 old_id == DofObject::invalid_id);
1470 di.push_back(old_id);
1471 }
1472 }
1473 }
1474 }
1475 }
1476
1477 std::sort(di.begin(), di.end());
1478 std::vector<dof_id_type>::iterator new_end =
1479 std::unique(di.begin(), di.end());
1480 std::vector<dof_id_type>(di.begin(), new_end).swap(di);
1481 }
1482 else if (elem->refinement_flag() == Elem::JUST_COARSENED)
1483 {
1484 std::vector<dof_id_type> di_child;
1485 di.clear();
1486 for (auto & child : elem->child_ref_range())
1487 {
1488 dof_map.old_dof_indices (&child, di_child);
1489 di.insert(di.end(), di_child.begin(), di_child.end());
1490 }
1491 }
1492 else
1493 dof_map.old_dof_indices (elem, di);
1494
1495 for (auto di_i : di)
1496 {
1497 // If we've just expanded a subdomain for a
1498 // subdomain-restricted variable, then we may have an
1499 // old_dof_object that doesn't have an old DoF for every
1500 // local index.
1501 if (di_i == DofObject::invalid_id)
1502 continue;
1503
1504 libmesh_assert_less(di_i, dof_map.n_old_dofs());
1505 if (di_i < first_old_dof || di_i >= end_old_dof)
1506 this->send_list.push_back(di_i);
1507 }
1508 } // end elem loop
1509}
dof_id_type first_old_dof(const processor_id_type proc) const
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition dof_object.h:473
@ JUST_COARSENED
Definition elem.h:1571
const DofMap & get_dof_map() const
Definition system.h:2448
unsigned int number() const
Definition system.h:2424
libmesh_assert(ctx)
uint8_t dof_id_type
Definition id_types.h:67

References libMesh::DofObject::dof_number(), libMesh::DofMapBase::end_old_dof(), libMesh::DofMapBase::first_old_dof(), libMesh::DofObject::get_old_dof_object(), libMesh::libmesh_assert(), libMesh::DofObject::n_comp_group(), libMesh::DofMapBase::n_old_dofs(), libMesh::DofObject::n_var_groups(), libMesh::DofObject::n_vars(), libMesh::DofMap::old_dof_indices(), and libMesh::Elem::parent().

◆ unique()

void libMesh::BuildProjectionList::unique ( )

Definition at line 1376 of file system_projection.C.

1377{
1378 // Sort the send list. After this duplicated
1379 // elements will be adjacent in the vector
1380 std::sort(this->send_list.begin(),
1381 this->send_list.end());
1382
1383 // Now use std::unique to remove duplicate entries
1384 std::vector<dof_id_type>::iterator new_end =
1385 std::unique (this->send_list.begin(),
1386 this->send_list.end());
1387
1388 // Remove the end of the send_list. Use the "swap trick"
1389 // from Effective STL
1390 std::vector<dof_id_type>
1391 (this->send_list.begin(), new_end).swap (this->send_list);
1392}

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

Member Data Documentation

◆ send_list

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

Definition at line 182 of file system_projection.C.

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

◆ system

const System& libMesh::BuildProjectionList::system
private

Definition at line 166 of file system_projection.C.


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