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)
63 : Serial_communicator(
false)
66 Comm = mpi_communicator;
69 Owns_mpi_comm = owns_mpi_comm;
76 : Owns_mpi_comm(
false), Serial_communicator(
true)
84 : Owns_mpi_comm(
false)
86 if (communicator.serial_communicator())
88 Serial_communicator =
true;
92 Comm = communicator.mpi_comm();
93 Serial_communicator =
false;
104 : Owns_mpi_comm(
false)
106 if (communicator_pt->serial_communicator())
108 Serial_communicator =
true;
112 Comm = communicator_pt->mpi_comm();
113 Serial_communicator =
false;
130 MPI_Comm_free(&Comm);
141 MPI_Comm_free(&Comm);
143 Owns_mpi_comm =
false;
144 if (communicator.serial_communicator())
146 Serial_communicator =
true;
150 Serial_communicator =
false;
151 Comm = communicator.mpi_comm();
160 if (Serial_communicator)
167 MPI_Comm_size(Comm, &n_proc);
179 if (Serial_communicator)
186 MPI_Comm_rank(Comm, &My_rank);
199 if (Serial_communicator != other_comm.serial_communicator())
203 else if (Serial_communicator)
210 MPI_Comm_compare(Comm, other_comm.mpi_comm(), &flag);
211 if (flag == MPI_IDENT)
226 return !(*
this == other_comm);
235 if (Serial_communicator)
237 std::ostringstream error_message_stream;
238 error_message_stream <<
"Attempted to split a serial communicator.";
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
270 if (Serial_communicator)
272 std::ostringstream error_message_stream;
274 <<
"Requested the MPI_Comm object for a serial communicator.";
275 throw OomphLibError(error_message_stream.str(),
285 bool serial_communicator()
const
287 return Serial_communicator;
291 void broadcast(
const int&
source, Vector<int>&
x)
296 unsigned long n_long;
302 n =
static_cast<int>(n_long);
306 MPI_Bcast(&
n, 1, MPI_INT,
source, this->mpi_comm());
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;
330 n =
static_cast<int>(n_long);
334 MPI_Bcast(&
n, 1, MPI_INT,
source, this->mpi_comm());
343 MPI_Bcast(&
x[0],
n, MPI_DOUBLE,
source, this->mpi_comm());
363 bool Serial_communicator;
Matrix< Scalar, Dynamic, Dynamic > DenseMatrix
Definition: BenchSparseUtil.h:23
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Definition: communicator.h:54
void operator=(const OomphCommunicator &communicator)
assignment operator
Definition: communicator.h:136
OomphCommunicator()
Serial constructor.
Definition: communicator.h:74
int my_rank() const
my rank
Definition: communicator.h:176
int nproc() const
number of processors
Definition: communicator.h:157
~OomphCommunicator()
Definition: communicator.h:125
OomphCommunicator(const OomphCommunicator &communicator)
Copy constructor.
Definition: communicator.h:82
OomphCommunicator(const OomphCommunicator *communicator_pt)
Pointer (copy) constructor.
Definition: communicator.h:102
bool operator!=(const OomphCommunicator &other_comm) const
Definition: communicator.h:224
bool operator==(const OomphCommunicator &other_comm) const
Definition: communicator.h:196
Definition: oomph_definitions.h:222
void source(const Vector< double > &x, Vector< double > &f)
Source function.
Definition: unstructured_two_d_circle.cc:46
void split(const DoubleVector &in_vector, Vector< DoubleVector * > &out_vector_pt)
Definition: double_vector.cc:1413
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
list x
Definition: plotDoE.py:28
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86