From 260fb78d711e6e96e9615efc23e625cc2f1640e0 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Wed, 23 Jan 2019 18:55:54 +0100 Subject: [PATCH] Begin faces dispatching for parallelism --- src/mesh/GmshReader.cpp | 34 +++++++++++++++++++++++++++++++++- src/scheme/AcousticSolver.hpp | 8 ++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/mesh/GmshReader.cpp b/src/mesh/GmshReader.cpp index 68e4dd3c4..96ade635a 100644 --- a/src/mesh/GmshReader.cpp +++ b/src/mesh/GmshReader.cpp @@ -336,6 +336,7 @@ class MeshDispatcher private: const MeshType& m_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>>; @@ -354,6 +355,31 @@ class MeshDispatcher return cell_new_owner; } + FaceValue<int> _getFaceNewOwner() + { + const auto& face_to_cell_matrix + = m_mesh.connectivity().faceToCellMatrix(); + + pout() << __FILE__ << ':' << __LINE__ << ": use Min function\n"; +#warning could use a better policy + FaceValue<int> face_new_owner(m_mesh.connectivity()); + parallel_for(m_mesh.numberOfFaces(), PASTIS_LAMBDA(const FaceId& l) { + const auto& face_to_cell = face_to_cell_matrix[l]; + CellId Jmin = face_to_cell[0]; + + for (size_t j=1; j<face_to_cell.size(); ++j) { + const CellId J = face_to_cell[j]; + if (J<Jmin) { + Jmin=J; + } + } + face_new_owner[l] = m_cell_new_owner[Jmin]; + }); + +#warning Add missing synchronize + return face_new_owner; + } + NodeValue<int> _getNodeNewOwner() { const auto& node_to_cell_matrix @@ -434,6 +460,12 @@ class MeshDispatcher 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 { @@ -473,6 +505,7 @@ class MeshDispatcher MeshDispatcher(const MeshType& mesh) : m_mesh(mesh), m_cell_new_owner(_getCellNewOwner()), + m_face_new_owner(_getFaceNewOwner()), m_node_new_owner(_getNodeNewOwner()), m_cell_list_to_send_by_proc(_buildCellListToSend()), m_nb_cell_to_send_by_proc(_buildNbCellToSend()), @@ -679,7 +712,6 @@ void GmshReader::_dispatch() } } - const NodeValue<const int>& new_node_owner = dispatcher.nodeNewOwner(); std::vector<Array<const int>> send_node_owner_by_proc(parallel::size()); for (size_t i_rank=0; i_rank<parallel::size(); ++i_rank) { diff --git a/src/scheme/AcousticSolver.hpp b/src/scheme/AcousticSolver.hpp index 4b3555020..04d2a524e 100644 --- a/src/scheme/AcousticSolver.hpp +++ b/src/scheme/AcousticSolver.hpp @@ -16,6 +16,7 @@ #include <BoundaryCondition.hpp> #include <SubItemValuePerItem.hpp> +#include <Messenger.hpp> template<typename MeshData> class AcousticSolver @@ -250,6 +251,13 @@ class AcousticSolver double acoustic_dt(const CellValue<const double>& Vj, const CellValue<const double>& cj) const { + if (parallel::size() > 1) { + perr() << __FILE__ << ':' << __LINE__ << ": stopping parallel execution\n"; + parallel::barrier(); + parallel::messenger().destroy(); + std::exit(0); + } + const NodeValuePerCell<const double>& ljr = m_mesh_data.ljr(); const auto& cell_to_node_matrix = m_mesh.connectivity().cellToNodeMatrix(); -- GitLab