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

Begin cleaning of mesh dispatcher code

parent cb1c4768
No related branches found
No related tags found
1 merge request!11Feature/mpi
...@@ -8,6 +8,7 @@ add_library( ...@@ -8,6 +8,7 @@ add_library(
Connectivity.cpp Connectivity.cpp
ConnectivityComputer.cpp ConnectivityComputer.cpp
GmshReader.cpp GmshReader.cpp
MeshDispatcher.cpp
SynchronizerManager.cpp) SynchronizerManager.cpp)
include_directories(${PASTIS_BINARY_DIR}/src/utils) include_directories(${PASTIS_BINARY_DIR}/src/utils)
......
This diff is collapsed.
This diff is collapsed.
#ifndef MESH_DISPATCHER_HPP
#define MESH_DISPATCHER_HPP
#include <Mesh.hpp>
#include <ItemValue.hpp>
#include <ItemValueUtils.hpp>
template <int Dimension>
class MeshDispatcher
{
public:
using MeshType = Mesh<Connectivity<Dimension>>;
private:
const MeshType& m_mesh;
std::shared_ptr<MeshType> m_dispatched_mesh;
CellValue<const int> m_cell_new_owner;
FaceValue<const int> m_face_new_owner;
NodeValue<const int> m_node_new_owner;
using CellListToSendByProc = std::vector<Array<const CellId>>;
const CellListToSendByProc m_cell_list_to_send_by_proc;
Array<int> m_nb_cell_to_send_by_proc;
Array<int> m_nb_cell_to_recv_by_proc;
CellValue<int> _getCellNewOwner();
FaceValue<int> _getFaceNewOwner();
NodeValue<int> _getNodeNewOwner();
const CellListToSendByProc _buildCellListToSend() const;
Array<int> _buildNbCellToSend();
public:
const std::shared_ptr<MeshType> dispatchedMesh() const
{
return m_dispatched_mesh;
}
PASTIS_INLINE
const CellValue<const int>& cellNewOwner() const
{
return m_cell_new_owner;
}
PASTIS_INLINE
const FaceValue<const int>& faceNewOwner() const
{
return m_face_new_owner;
}
PASTIS_INLINE
const NodeValue<const int>& nodeNewOwner() const
{
return m_node_new_owner;
}
template<typename DataType, typename ConnectivityPtr>
std::vector<Array<std::remove_const_t<DataType>>>
exchange(ItemValue<DataType, ItemType::cell, ConnectivityPtr> cell_value) const
{
using MutableDataType = std::remove_const_t<DataType>;
std::vector<Array<DataType>> cell_value_to_send_by_proc(parallel::size());
for (size_t i=0; i<parallel::size(); ++i) {
const Array<const CellId>& cell_list = m_cell_list_to_send_by_proc[i];
Array<MutableDataType> cell_value_list(cell_list.size());
parallel_for (cell_list.size(), PASTIS_LAMBDA(const CellId& cell_id) {
cell_value_list[cell_id] = cell_value[cell_list[cell_id]];
});
cell_value_to_send_by_proc[i] = cell_value_list;
}
std::vector<Array<MutableDataType>> recv_cell_value_by_proc(parallel::size());
for (size_t i=0; i<parallel::size(); ++i) {
recv_cell_value_by_proc[i] = Array<MutableDataType>(m_nb_cell_to_recv_by_proc[i]);
}
parallel::exchange(cell_value_to_send_by_proc, recv_cell_value_by_proc);
return recv_cell_value_by_proc;
}
[[deprecated]]
const CellListToSendByProc& cell_list_to_send_by_proc() const
{
return m_cell_list_to_send_by_proc;
}
MeshDispatcher(const MeshType& mesh);
MeshDispatcher(const MeshDispatcher&) = delete;
~MeshDispatcher() = default;
};
#endif // MESH_DISPATCHER_HPP
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment