26 #ifndef OOMPH_COMMUNICATOR_CLASS_HEADER
27 #define OOMPH_COMMUNICATOR_CLASS_HEADER
31 #include <oomph-lib-config.h>
62 const bool& owns_mpi_comm =
false)
66 Comm = mpi_communicator;
86 if (communicator.serial_communicator())
92 Comm = communicator.mpi_comm();
106 if (communicator_pt->serial_communicator())
112 Comm = communicator_pt->mpi_comm();
130 MPI_Comm_free(&
Comm);
141 MPI_Comm_free(&
Comm);
144 if (communicator.serial_communicator())
151 Comm = communicator.mpi_comm();
167 MPI_Comm_size(
Comm, &n_proc);
186 MPI_Comm_rank(
Comm, &My_rank);
210 MPI_Comm_compare(
Comm, other_comm.mpi_comm(), &flag);
211 if (flag == MPI_IDENT)
226 return !(*
this == other_comm);
237 std::ostringstream error_message_stream;
238 error_message_stream <<
"Attempted to split a serial communicator.";
239 throw OomphLibError(error_message_stream.str(),
240 OOMPH_CURRENT_FUNCTION,
241 OOMPH_EXCEPTION_LOCATION);
249 MPI_Comm* mpi_comm_pt =
new MPI_Comm;
252 MPI_Comm_split(
Comm, color, key, mpi_comm_pt);
260 return split_comm_pt;
267 MPI_Comm mpi_comm()
const
272 std::ostringstream error_message_stream;
274 <<
"Requested the MPI_Comm object for a serial communicator.";
275 throw OomphLibError(error_message_stream.str(),
276 OOMPH_CURRENT_FUNCTION,
277 OOMPH_EXCEPTION_LOCATION);
285 bool serial_communicator()
const
291 void broadcast(
const int& source, Vector<int>& x)
296 unsigned long n_long;
297 if (this->my_rank() == source)
302 n =
static_cast<int>(n_long);
306 MPI_Bcast(&n, 1, MPI_INT, source, this->mpi_comm());
309 if (this->my_rank() != source)
315 MPI_Bcast(&x[0], n, MPI_INT, source, this->mpi_comm());
319 void broadcast(
const int& source, Vector<double>& x)
324 unsigned long n_long;
325 if (this->my_rank() == source)
330 n =
static_cast<int>(n_long);
334 MPI_Bcast(&n, 1, MPI_INT, source, this->mpi_comm());
337 if (this->my_rank() != source)
343 MPI_Bcast(&x[0], n, MPI_DOUBLE, source, this->mpi_comm());
347 void broadcast(
const int& source, DenseMatrix<double>& x);
An oomph-lib wrapper to the MPI_Comm communicator object. Just contains an MPI_Comm object (which is ...
MPI_Comm Comm
the MPI_Comm communicator
OomphCommunicator()
Serial constructor.
bool Owns_mpi_comm
boolean indiacting whether this communicator owns the underlying MPI_Comm - if so the destructor will...
bool Serial_communicator
boolean to indicate if this communicator is for serial problems. This is true when serial codes are c...
OomphCommunicator(const MPI_Comm mpi_communicator, const bool &owns_mpi_comm=false)
Construct a communicator from a MPI_Comm object. if the bool owns_mpi_comm is true then this communic...
void split(const DoubleVector &in_vector, Vector< DoubleVector * > &out_vector_pt)
Split a DoubleVector into the out DoubleVectors. Let vec_A be the in Vector, and let vec_B and vec_C ...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...