Skip to content
Snippets Groups Projects
Commit af1fa0f8 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Continue clean-up

Mainly replace _get-like functions by _build-like calls. This removes many
unnecessary references.
parent 9d7da3cd
No related branches found
No related tags found
1 merge request!11Feature/mpi
......@@ -53,7 +53,6 @@ _buildItemToExchangeLists()
{
this->_buildItemListToSend<item_type>();
this->_buildNumberOfItemToExchange<item_type>();
if constexpr (item_type == ItemType::cell) {
this->_buildCellNumberIdMap();
}
......@@ -195,13 +194,13 @@ _gatherFrom(const SubItemValuePerItem<DataType, ItemOfItem, ConnectivityPtr>& da
data_to_send_by_proc[i_rank] = convert_to_array(data_by_item_vector);
}
const auto& number_of_item_per_item_by_proc =
this->_dispatchedInfo<ItemOfItem>().m_recv_number_of_item_per_item_by_proc;
const auto& number_of_sub_item_per_item_to_recv_by_proc =
this->_dispatchedInfo<ItemOfItem>().m_number_of_sub_item_per_item_to_recv_by_proc;
std::vector<Array<MutableDataType>> recv_data_to_gather_by_proc(parallel::size());
for (size_t i_rank=0; i_rank < parallel::size(); ++i_rank) {
recv_data_to_gather_by_proc[i_rank]
= Array<MutableDataType>(sum(number_of_item_per_item_by_proc[i_rank]));
= Array<MutableDataType>(sum(number_of_sub_item_per_item_to_recv_by_proc[i_rank]));
}
parallel::exchange(data_to_send_by_proc, recv_data_to_gather_by_proc);
......@@ -212,7 +211,7 @@ _gatherFrom(const SubItemValuePerItem<DataType, ItemOfItem, ConnectivityPtr>& da
for (size_t i_rank=0; i_rank < parallel::size(); ++i_rank) {
int l=0;
for (size_t i=0; i<item_list_to_recv_size_by_proc[i_rank]; ++i) {
Array<MutableDataType> data_vector(number_of_item_per_item_by_proc[i_rank][i]);
Array<MutableDataType> data_vector(number_of_sub_item_per_item_to_recv_by_proc[i_rank][i]);
for (size_t k=0; k<data_vector.size(); ++k) {
data_vector[k] = recv_data_to_gather_by_proc[i_rank][l++];
}
......@@ -241,16 +240,18 @@ _buildCellNumberIdMap()
template <int Dimension>
template <typename ItemOfItemT>
void
ConnectivityDispatcher<Dimension>::
_buildSubItemNumberToIdMap(const std::vector<Array<const int>>& recv_cell_sub_item_number_by_proc)
ConnectivityDispatcher<Dimension>::_buildSubItemNumberToIdMap()
{
static_assert(ItemOfItemT::item_type == ItemType::cell, "Dispatcher requires to be built using cell as master entities");
const auto& cell_sub_item_number_to_recv_by_proc
= this->_dispatchedInfo<ItemOfItemT>().m_sub_item_of_item_numbers_to_recv_by_proc;
auto& sub_item_number_id_map = this->_dispatchedInfo<ItemOfItemT::sub_item_type>().m_number_to_id_map;
for (size_t i_rank=0; i_rank<parallel::size(); ++i_rank) {
int sub_item_id=0;
for (size_t i=0; i<recv_cell_sub_item_number_by_proc[i_rank].size(); ++i) {
int sub_item_number = recv_cell_sub_item_number_by_proc[i_rank][i];
for (size_t i=0; i<cell_sub_item_number_to_recv_by_proc[i_rank].size(); ++i) {
int sub_item_number = cell_sub_item_number_to_recv_by_proc[i_rank][i];
auto [iterator, inserted] = sub_item_number_id_map.insert(std::make_pair(sub_item_number, sub_item_id));
if (inserted) sub_item_id++;
}
......@@ -259,8 +260,8 @@ _buildSubItemNumberToIdMap(const std::vector<Array<const int>>& recv_cell_sub_it
template <int Dimension>
template <typename SubItemOfItemT>
std::vector<Array<const int>>
ConnectivityDispatcher<Dimension>::_getRecvNumberOfSubItemPerItemByProc()
void
ConnectivityDispatcher<Dimension>::_buildNumberOfSubItemPerItemToRecvByProc()
{
const auto& item_to_sub_item_matrix
= m_connectivity.template getItemToItemMatrix<SubItemOfItemT::item_type,
......@@ -272,14 +273,15 @@ ConnectivityDispatcher<Dimension>::_getRecvNumberOfSubItemPerItemByProc()
parallel_for(number_of_sub_item_per_item.size(), PASTIS_LAMBDA(const ItemId& j){
number_of_sub_item_per_item[j] = item_to_sub_item_matrix[j].size();
});
return this->exchange(number_of_sub_item_per_item);
this->_dispatchedInfo<SubItemOfItemT>().m_number_of_sub_item_per_item_to_recv_by_proc =
this->exchange(number_of_sub_item_per_item);
}
template <int Dimension>
template <typename SubItemOfItemT>
std::vector<Array<const int>>
ConnectivityDispatcher<Dimension>::
_getRecvItemSubItemNumberingByProc(const std::vector<Array<const int>>& recv_number_of_sub_item_per_item_by_proc)
void
ConnectivityDispatcher<Dimension>::_buildSubItemNumbersToRecvByProc()
{
std::vector<Array<const int>> item_sub_item_numbering_to_send_by_proc =
[&] () {
......@@ -312,10 +314,13 @@ _getRecvItemSubItemNumberingByProc(const std::vector<Array<const int>>& recv_num
return item_sub_item_numbering_to_send_by_proc;
} ();
const auto& number_of_sub_item_per_item_to_recv_by_proc =
this->_dispatchedInfo<SubItemOfItemT>().m_number_of_sub_item_per_item_to_recv_by_proc;
std::vector<Array<int>> recv_item_sub_item_numbering_by_proc(parallel::size());
for (size_t i_rank=0; i_rank < parallel::size(); ++i_rank) {
recv_item_sub_item_numbering_by_proc[i_rank]
= Array<int>(sum(recv_number_of_sub_item_per_item_by_proc[i_rank]));
= Array<int>(sum(number_of_sub_item_per_item_to_recv_by_proc[i_rank]));
}
parallel::exchange(item_sub_item_numbering_to_send_by_proc, recv_item_sub_item_numbering_by_proc);
......@@ -323,14 +328,15 @@ _getRecvItemSubItemNumberingByProc(const std::vector<Array<const int>>& recv_num
for (size_t i_rank=0; i_rank < parallel::size(); ++i_rank) {
const_recv_item_sub_item_numbering_by_proc[i_rank] = recv_item_sub_item_numbering_by_proc[i_rank];
}
return const_recv_item_sub_item_numbering_by_proc;
this->_dispatchedInfo<SubItemOfItemT>().m_sub_item_of_item_numbers_to_recv_by_proc
= const_recv_item_sub_item_numbering_by_proc;
}
template <int Dimension>
template <typename ItemOfItemT>
void
ConnectivityDispatcher<Dimension>::
_buildItemToItemDescriptor()
ConnectivityDispatcher<Dimension>::_buildItemToSubItemDescriptor()
{
constexpr ItemType item_type = ItemOfItemT::item_type;
constexpr ItemType sub_item_type = ItemOfItemT::sub_item_type;
......@@ -338,20 +344,20 @@ _buildItemToItemDescriptor()
const auto& item_list_to_recv_size_by_proc =
this->_dispatchedInfo<item_type>().m_list_to_recv_size_by_proc;
const auto& recv_number_of_item_per_item_by_proc =
this->_dispatchedInfo<ItemOfItemT>().m_recv_number_of_item_per_item_by_proc;
const auto& number_of_sub_item_per_item_to_recv_by_proc =
this->_dispatchedInfo<ItemOfItemT>().m_number_of_sub_item_per_item_to_recv_by_proc;
const auto& sub_item_number_id_map =
this->_dispatchedInfo<sub_item_type>().m_number_to_id_map;
const auto& recv_item_of_item_numbers_by_proc =
this->_dispatchedInfo<ItemOfItemT>().m_recv_item_of_item_numbers_by_proc;
this->_dispatchedInfo<ItemOfItemT>().m_sub_item_of_item_numbers_to_recv_by_proc;
for (size_t i_rank=0; i_rank < parallel::size(); ++i_rank) {
int l=0;
for (size_t i=0; i<item_list_to_recv_size_by_proc[i_rank]; ++i) {
std::vector<unsigned int> sub_item_vector;
for (int k=0; k<recv_number_of_item_per_item_by_proc[i_rank][i]; ++k) {
for (int k=0; k<number_of_sub_item_per_item_to_recv_by_proc[i_rank][i]; ++k) {
const auto& searched_sub_item_id =
sub_item_number_id_map.find(recv_item_of_item_numbers_by_proc[i_rank][l++]);
Assert(searched_sub_item_id != sub_item_number_id_map.end());
......@@ -411,44 +417,22 @@ void
ConnectivityDispatcher<Dimension>::_dispatchFaces()
{
if constexpr (Dimension>1) {
this->_dispatchedInfo<FaceOfCell>().m_recv_number_of_item_per_item_by_proc =
_getRecvNumberOfSubItemPerItemByProc<FaceOfCell>();
{
const auto& recv_number_of_face_per_cell_by_proc =
this->_dispatchedInfo<FaceOfCell>().m_recv_number_of_item_per_item_by_proc;
std::vector<Array<const int>>& recv_cell_face_numbering_by_proc
= this->_dispatchedInfo<FaceOfCell>().m_recv_item_of_item_numbers_by_proc;
recv_cell_face_numbering_by_proc =
this->_getRecvItemSubItemNumberingByProc<FaceOfCell>(recv_number_of_face_per_cell_by_proc);
this->_buildSubItemNumberToIdMap<FaceOfCell>(recv_cell_face_numbering_by_proc);
}
this->_buildNumberOfSubItemPerItemToRecvByProc<FaceOfCell>();
this->_buildSubItemNumbersToRecvByProc<FaceOfCell>();
this->_buildSubItemNumberToIdMap<FaceOfCell>();
this->_buildItemToExchangeLists<ItemType::face>();
this->_gatherFrom(m_connectivity.template number<ItemType::face>(), m_new_descriptor.face_number_vector);
this->_buildItemToItemDescriptor<FaceOfCell>();
this->_buildItemToSubItemDescriptor<FaceOfCell>();
this->_gatherFrom(m_connectivity.cellFaceIsReversed(), m_new_descriptor.cell_face_is_reversed_vector);
this->_gatherFrom(this->_dispatchedInfo<ItemType::face>().m_new_owner, m_new_descriptor.face_owner_vector);
{
auto& recv_number_of_node_per_face_by_proc =
this->_dispatchedInfo<NodeOfFace>().m_recv_number_of_item_per_item_by_proc;
recv_number_of_node_per_face_by_proc =
_getRecvNumberOfSubItemPerItemByProc<NodeOfFace>();
this->_dispatchedInfo<NodeOfFace>().m_recv_item_of_item_numbers_by_proc
= this->_getRecvItemSubItemNumberingByProc<NodeOfFace>(recv_number_of_node_per_face_by_proc);
this->_buildItemToItemDescriptor<NodeOfFace>();
}
this->_buildNumberOfSubItemPerItemToRecvByProc<NodeOfFace>();
this->_buildSubItemNumbersToRecvByProc<NodeOfFace>();
this->_buildItemToSubItemDescriptor<NodeOfFace>();
// Getting references
Array<const size_t> number_of_ref_face_list_per_proc
......@@ -624,21 +608,13 @@ ConnectivityDispatcher<Dimension>::ConnectivityDispatcher(const ConnectivityType
this->_buildItemToExchangeLists<ItemType::cell>();
auto& recv_number_of_node_per_cell_by_proc=
this->_dispatchedInfo<NodeOfCell>().m_recv_number_of_item_per_item_by_proc;
recv_number_of_node_per_cell_by_proc
= this->_getRecvNumberOfSubItemPerItemByProc<NodeOfCell>();
auto& recv_cell_node_numbering_by_proc =
this->_dispatchedInfo<NodeOfCell>().m_recv_item_of_item_numbers_by_proc;
this->_buildNumberOfSubItemPerItemToRecvByProc<NodeOfCell>();
recv_cell_node_numbering_by_proc
= this->_getRecvItemSubItemNumberingByProc<NodeOfCell>(recv_number_of_node_per_cell_by_proc);
this->_buildSubItemNumbersToRecvByProc<NodeOfCell>();
this->_gatherFrom(m_connectivity.template number<ItemType::cell>(), m_new_descriptor.cell_number_vector);
this->_buildSubItemNumberToIdMap<NodeOfCell>(recv_cell_node_numbering_by_proc);
this->_buildSubItemNumberToIdMap<NodeOfCell>();
this->_buildItemToExchangeLists<ItemType::node>();
......@@ -649,7 +625,7 @@ ConnectivityDispatcher<Dimension>::ConnectivityDispatcher(const ConnectivityType
this->_gatherFrom(m_connectivity.template number<ItemType::node>(), m_new_descriptor.node_number_vector);
this->_gatherFrom(this->_dispatchedInfo<ItemType::node>().m_new_owner, m_new_descriptor.node_owner_vector);
this->_buildItemToItemDescriptor<NodeOfCell>();
this->_buildItemToSubItemDescriptor<NodeOfCell>();
this->_dispatchFaces();
......
......@@ -68,8 +68,8 @@ class ConnectivityDispatcher
template <typename ItemToItem>
struct DispatchedItemOfItemInfo
{
std::vector<Array<const int>> m_recv_number_of_item_per_item_by_proc;
std::vector<Array<const int>> m_recv_item_of_item_numbers_by_proc;
std::vector<Array<const int>> m_number_of_sub_item_per_item_to_recv_by_proc;
std::vector<Array<const int>> m_sub_item_of_item_numbers_to_recv_by_proc;
};
DispatchedItemOfItemInfo<NodeOfCell> m_dispatched_node_of_cell_info;
......@@ -163,7 +163,7 @@ class ConnectivityDispatcher
void _buildCellNumberIdMap();
template <typename ItemOfItemT>
void _buildSubItemNumberToIdMap(const std::vector<Array<const int>>& recv_cell_node_number_by_proc);
void _buildSubItemNumberToIdMap();
template <ItemType item_type>
void _buildItemToExchangeLists();
......@@ -172,7 +172,7 @@ class ConnectivityDispatcher
void _buildNumberOfItemToExchange();
template <typename ItemOfItemT>
void _buildItemToItemDescriptor();
void _buildItemToSubItemDescriptor();
void _dispatchFaces();
......@@ -185,12 +185,10 @@ class ConnectivityDispatcher
std::vector<Array<std::remove_const_t<DataType>>>& gathered_vector);
template <typename SubItemOfItemT>
std::vector<Array<const int>>
_getRecvNumberOfSubItemPerItemByProc();
void _buildNumberOfSubItemPerItemToRecvByProc();
template <typename SubItemOfItemT>
std::vector<Array<const int>>
_getRecvItemSubItemNumberingByProc(const std::vector<Array<const int>>& recv_number_of_sub_item_per_item_by_proc);
void _buildSubItemNumbersToRecvByProc();
template <ItemType item_type>
void _buildRecvItemIdCorrespondanceByProc();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment