55 auto dir = location.parent_path();
67 return this->size ==
size;
75 return this->name ==
name;
83 return this->rank ==
rank;
94 switch (requirement) {
128 Par::Parallel::CommState::world()->synchronize();
130 Par::Parallel::CommState::world()->synchronize();
139 const int globalRank = baseComm->rank();
140 const int available = baseComm->size();
148 auto required = groups.
back();
149 if (required > available) {
154 if (globalRank >= required) {
181#ifndef PRECICE_NO_MPI
202 er.setDirectory(
"./precice-profiling");
221 switch (options.
type) {
235 "Acceptor \"" + acceptor +
"\" not defined in this context."};
239 "Requestor \"" + requestor +
"\" not defined in this context."};
243 m2n->acceptPrimaryRankConnection(acceptor, requestor);
244 }
else if (
isNamed(requestor)) {
245 m2n->requestPrimaryRankConnection(acceptor, requestor);
247 throw std::runtime_error{
"You try to connect " + acceptor +
" and " + requestor +
", but this context is named " +
name};
255 return "This test context is invalid!";
258 os <<
"Test context";
262 os <<
" represents \"" <<
name <<
'"';
264 os <<
" and runs on rank " <<
rank <<
" out of " <<
size <<
'.';
267 os <<
" Initialized: {";
269 os <<
" IntraComm Communication ";
T weakly_canonical(T... args)
Provides connection methods for processes located in one communicator.
Implements Communication by using sockets.
M2N communication class. This layer is necessary since communication between two participants can be ...
static EventRegistry & instance()
Returns the only instance (singleton) of the EventRegistry class.
void finalize()
Sets the global end time and flushes buffers.
void handleOption(Participants &participants, ParticipantState participant)
bool _petsc
whether to initialize PETSc
bool isRank(Rank rank) const
Check whether this context has a given rank inside the Participant.
std::string prefix(const std::string &filename) const
void initialize(const Participants &participants)
Main entrypoint.
bool _initIntraComm
whether to initialize an intra-participant connection
bool _simple
whether this Context was created with a Ranks constructor
m2n::PtrM2N connectPrimaryRanks(const std::string &acceptor, const std::string &requestor, const ConnectionOptions &options=ConnectionOptions{}) const
void initializePetsc()
Initialize PETSc if required.
bool invalid
whether this context is valid or not
void initializeMPI(const Participants &participants)
bool isNamed(const std::string &name) const
Check whether this context has a given name.
int size
the size of the Communicator of the current participant
std::string describe() const
Provides a user- and log-friendly description of the current context.
bool _events
whether to initialize events
bool hasSize(int size) const
Check whether this context has a given size.
utils::Parallel::CommStatePtr _contextComm
the MPI communicator of the context
void initializeIntraComm()
Initialize the intra-participant communication connection if requested.
std::vector< std::string > _names
contains the name of every known Participant
void initializeEvents()
Initialize Events if required.
Rank rank
the rank of the current participant
std::string name
the name of the current participant
void setContextFrom(const ParticipantState &p)
std::string config() const
static com::PtrCommunication & getCommunication()
Intra-participant communication.
static void configure(Rank rank, int size)
Configures the intra-participant communication.
Utility class for managing MPI operations.
static void resetCommState()
static CommStatePtr current()
Returns an owning pointer to the current CommState.
static void resetManagedMPI()
static void splitCommunicator(std::optional< int > group=std::nullopt)
Splits and creates a local MPI communicator according to groupName.
static void finalize()
Finalizes Petsc environment.
static void initialize(utils::Parallel::Communicator comm)
Initializes the Petsc environment.
T emplace_back(T... args)
std::shared_ptr< Communication > PtrCommunication
void setMPIRank(int const rank)
void setParticipant(std::string const &participant)
std::shared_ptr< M2N > PtrM2N
contains the testing framework.
@ PETSc
Require to initialize PETSc. This implies the initialization of Events.
@ Events
Require to initialize Event.
std::string getTestPath()
Returns the full path to the file containing the current test.
std::string getTestName()
Returns the name of the current test.
Represents a ParticipantState in a test.
int size
the amount of ranks this participant runs on
std::string name
the name of the participant
bool initIntraComm
whether to initialize an intra-participant communication for this participant