29inline constexpr Ranks operator""_ranks(
unsigned long long value)
31 return (value <= 1) ?
throw std::runtime_error{
"Cannot create a single rank with _ranks()! Use _rank() instead!"} :
Ranks{
static_cast<int>(value)};
40inline constexpr Ranks operator""_rank(
unsigned long long value)
42 return (value == 1) ?
Ranks{1} :
throw std::runtime_error{
"Cannot create multiple ranks with _rank()! Use _ranks() instead!"};
91static_assert(
std::is_same<ParticipantState &,
decltype(
""_on(1_rank))>::value,
"");
92static_assert(
std::is_same<ParticipantState &,
decltype(
""_on(2_ranks))>::value,
"");
182 template <
class... T>
199 template <
class... T>
214 template <
class... T>
305 template <
class LastOption>
311 template <
class NextOption,
class... Rest>
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.
void handleOptions(Participants &participants, NextOption &next, Rest &... rest)
void initialize(const Participants &participants)
Main entrypoint.
TestContext(Ranks ranks, T... args)
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
std::vector< ParticipantState > Participants
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
void handleOptions(Participants &participants, LastOption &last)
auto comm()
Returns a pointer to the MPI communicator of this context.
TestContext()=default
Create a context representing an unnamed serial Participant.
std::string name
the name of the current participant
void setContextFrom(const ParticipantState &p)
std::string config() const
@ PETSc
Require to initialize PETSc. This implies the initialization of Events.
@ Events
Require to initialize Event.
Main namespace of the precice library.
ConnectionOptions()=default
Represents a ParticipantState in a test.
int size
the amount of ranks this participant runs on
std::string name
the name of the participant
ParticipantState & operator()(Ranks rsize)
bool initIntraComm
whether to initialize an intra-participant communication for this participant
ParticipantState(std::string n)
Constructs a serial participant with a given name.
ParticipantState & setupIntraComm()