Select Git revision
ConnectivityDispatcher.cpp
ConnectivityDispatcher.cpp 30.18 KiB
#include <mesh/ConnectivityDispatcher.hpp>
#include <mesh/ItemOfItemType.hpp>
#include <utils/CRSGraph.hpp>
#include <utils/Partitioner.hpp>
#include <iostream>
#include <unordered_map>
template <int Dimension>
template <ItemType item_type>
void
ConnectivityDispatcher<Dimension>::_buildNewOwner()
{
if constexpr (item_type == ItemType::cell) {
CRSGraph connectivity_graph = m_connectivity.cellToCellGraph();
Partitioner P;
CellValue<int> cell_new_owner(m_connectivity, P.partition(connectivity_graph));
this->_dispatchedInfo<ItemType::cell>().m_new_owner = cell_new_owner;
} else {
const auto& item_to_cell_matrix = m_connectivity.template getItemToItemMatrix<item_type, ItemType::cell>();
const auto& cell_number = m_connectivity.cellNumber();
const auto& cell_new_owner = this->_dispatchedInfo<ItemType::cell>().m_new_owner;
using ItemId = ItemIdT<item_type>;
ItemValue<int, item_type> item_new_owner(m_connectivity);
parallel_for(
item_new_owner.numberOfItems(), PUGS_LAMBDA(const ItemId& l) {
const auto& item_to_cell = item_to_cell_matrix[l];
CellId Jmin = item_to_cell[0];
for (size_t j = 1; j < item_to_cell.size(); ++j) {
const CellId J = item_to_cell[j];
if (cell_number[J] < cell_number[Jmin]) {
Jmin = J;
}
}
item_new_owner[l] = cell_new_owner[Jmin];
});
synchronize(item_new_owner);
this->_dispatchedInfo<item_type>().m_new_owner = item_new_owner;
}
}
template <int Dimension>
template <ItemType item_type>
void
ConnectivityDispatcher<Dimension>::_buildItemToExchangeLists()
{
this->_buildItemListToSend<item_type>();
this->_buildNumberOfItemToExchange<item_type>();
if constexpr (item_type == ItemType::cell) {
this->_buildCellNumberIdMap();
}
this->_buildRecvItemIdCorrespondanceByProc<item_type>();
}
template <int Dimension>
template <ItemType item_type>
void
ConnectivityDispatcher<Dimension>::_buildItemListToSend()
{
if constexpr (item_type == ItemType::cell) {
const auto& node_to_cell_matrix = m_connectivity.nodeToCellMatrix();
const auto& cell_to_node_matrix = m_connectivity.cellToNodeMatrix();