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

Constructor & Destructor Documentation

◆ BuildProjectionList() [1/2]

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

Definition at line 168 of file system_projection.C.

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

◆ BuildProjectionList() [2/2]

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

Definition at line 173 of file system_projection.C.

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

Member Function Documentation

◆ join()

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

Definition at line 1524 of file system_projection.C.

1525{
1526 // Joining simply requires I add the dof indices from the other object
1527 this->send_list.insert(this->send_list.end(),
1528 other.send_list.begin(),
1529 other.send_list.end());
1530}

References send_list.

◆ operator()()

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

Definition at line 1407 of file system_projection.C.

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

1388{
1389 // Sort the send list. After this duplicated
1390 // elements will be adjacent in the vector
1391 std::sort(this->send_list.begin(),
1392 this->send_list.end());
1393
1394 // Now use std::unique to remove duplicate entries
1395 std::vector<dof_id_type>::iterator new_end =
1396 std::unique (this->send_list.begin(),
1397 this->send_list.end());
1398
1399 // Remove the end of the send_list. Use the "swap trick"
1400 // from Effective STL
1401 std::vector<dof_id_type>
1402 (this->send_list.begin(), new_end).swap (this->send_list);
1403}

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

Member Data Documentation

◆ send_list

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

Definition at line 181 of file system_projection.C.

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

◆ system

const System& libMesh::BuildProjectionList::system
private

Definition at line 165 of file system_projection.C.


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