added: broadcast wrapper to ProcessAdm

This commit is contained in:
Arne Morten Kvarving
2022-05-19 11:27:05 +02:00
parent 933bc34944
commit 6736f7829f
2 changed files with 13 additions and 0 deletions

View File

@@ -53,6 +53,14 @@ ProcessAdm::ProcessAdm(const ProcessAdm& adm) : cout(adm.cout)
}
void ProcessAdm::broadcast (std::vector<double>& vec, int root) const
{
#ifdef HAVE_MPI
MPI_Bcast(vec.data(), vec.size(), MPI_DOUBLE, root, comm);
#endif
}
#ifdef HAVE_MPI
ProcessAdm::ProcessAdm(bool) : cout(std::cout)
{

View File

@@ -69,6 +69,11 @@ public:
//! \brief Return if parallel
int isParallel() const { return parallel; }
//! \brief Broadcast for a double vector.
//! \param vec Double array to broadcast
//! \param root Node to broadcast from
void broadcast(std::vector<double>& vec, int root) const;
#if defined(HAS_PETSC) || defined(HAVE_MPI)
//! \brief Return MPI communicator
MPI_Comm* getCommunicator() { return &comm; }