50 PtrDataConfiguration dataConfig(
new DataConfiguration(root));
51 PtrMeshConfiguration meshConfig(
new MeshConfiguration(root, dataConfig));
60 meshConfig->meshes().at(0)->createVertex(Eigen::Vector3d(1.0, 1.0, 1.0));
61 meshConfig->meshes().at(0)->createVertex(Eigen::Vector3d(2.0, 1.0, -1.0));
62 meshConfig->meshes().at(0)->createVertex(Eigen::Vector3d(3.0, 1.0, 1.0));
63 meshConfig->meshes().at(0)->createVertex(Eigen::Vector3d(4.0, 1.0, -1.0));
65 m2n::PtrM2N m2n0 = m2nConfig->getM2N(nameParticipant0, nameParticipant1);
66 m2n::PtrM2N m2n1 = m2nConfig->getM2N(nameParticipant1, nameParticipant2);
68 if (context.
isNamed(nameParticipant0)) {
69 connect(nameParticipant0, nameParticipant1, context.
name, m2n0);
70 }
else if (context.
isNamed(nameParticipant1)) {
71 connect(nameParticipant0, nameParticipant1, context.
name, m2n0);
72 connect(nameParticipant1, nameParticipant2, context.
name, m2n1);
74 connect(nameParticipant1, nameParticipant2, context.
name, m2n1);
78 context.
name, meshConfig);
86 BOOST_TEST(meshConfig->meshes().size() == 1);
88 BOOST_TEST(mesh->data().size() == 3);
89 BOOST_TEST(mesh->nVertices() > 0);
91 double computedTime = 0.0;
92 int computedTimesteps = 0;
94 if (participantName ==
std::string(
"Participant0")) {
95 mesh->data(0)->setSampleAtTime(0,
time::Sample{1, mesh->data(0)->values()});
101 BOOST_REQUIRE(computedTime < 1.1);
107 mesh->data(0)->setSampleAtTime(computedTime + stepSize,
time::Sample{1, mesh->data(0)->values()});
108 BOOST_TEST(cplScheme->
getTime() == computedTime);
110 BOOST_TEST(cplScheme->
getTime() == computedTime + stepSize);
119 computedTime += stepSize;
127 BOOST_TEST(computedTimesteps == 10);
131 }
else if (participantName ==
std::string(
"Participant1")) {
132 auto ddims = mesh->data(1)->getDimensions();
133 mesh->data(1)->setSampleAtTime(0,
time::Sample{ddims, mesh->data(1)->values()});
139 BOOST_REQUIRE(computedTime < 1.1);
145 mesh->data(1)->setSampleAtTime(computedTime + stepSize,
time::Sample{ddims, mesh->data(1)->values()});
146 BOOST_TEST(cplScheme->
getTime() == computedTime);
148 BOOST_TEST(cplScheme->
getTime() == computedTime + stepSize);
157 computedTime += stepSize;
165 BOOST_TEST(computedTimesteps == 10);
170 auto ddims = mesh->data(2)->getDimensions();
171 BOOST_TEST(participantName ==
std::string(
"Participant2"), participantName);
172 mesh->data(2)->setSampleAtTime(0,
time::Sample{ddims, mesh->data(2)->values()});
178 BOOST_REQUIRE(computedTime < 1.1);
185 BOOST_TEST(cplScheme->
getTime() == computedTime);
187 BOOST_TEST(cplScheme->
getTime() == computedTime + stepSize);
196 computedTime += stepSize;
205 BOOST_TEST(computedTimesteps == 10);
217 BOOST_TEST(communication);
218 BOOST_TEST(not communication->isConnected());
219 useOnlyPrimaryCom(communication) =
true;
220 if (participant0 == localParticipant) {
221 communication->requestPrimaryRankConnection(participant1, participant0);
223 BOOST_TEST(participant1 == localParticipant);
224 communication->acceptPrimaryRankConnection(participant1, participant0);
235 int numberIterations = 1;
236 int maxTimeWindows = 10;
253 BOOST_TEST(advances == 10);
262 int numberIterations = 1;
263 int maxTimeWindows = 10;
285 BOOST_TEST(advances == 10);
295 int numberIterations = 1;
296 int maxTimeWindows = 10;
298 numberIterations = 2;
315 BOOST_TEST_CONTEXT(
"Advance Nr " << advances)
319 if (advances % 2 == 0) {
320 BOOST_TEST(scheme2->
isActionRequired(CouplingScheme::Action::WriteCheckpoint));
323 BOOST_TEST(scheme2->
isActionRequired(CouplingScheme::Action::ReadCheckpoint));
329 BOOST_TEST(advances == 20);
338 int numberIterations = 2;
339 int maxTimeWindows = 10;
341 numberIterations = 1;
355 if (advances % 2 == 0) {
356 BOOST_TEST(scheme1->
isActionRequired(CouplingScheme::Action::WriteCheckpoint));
359 BOOST_TEST(scheme1->
isActionRequired(CouplingScheme::Action::ReadCheckpoint));
364 BOOST_TEST(advances == 20);
373 int numberIterations = 1;
374 int maxTimeWindows = 10;
377 numberIterations = 3;
392 if (advances % 3 == 0) {
393 BOOST_TEST(scheme2->
isActionRequired(CouplingScheme::Action::WriteCheckpoint));
396 BOOST_TEST(scheme2->
isActionRequired(CouplingScheme::Action::ReadCheckpoint));
397 BOOST_TEST(scheme1->
getTimeWindows() - 1 == (advances + (3 - advances % 3)) / 3);
401 BOOST_TEST(advances == 30);
410 int numberIterations = 3;
411 int maxTimeWindows = 10;
413 numberIterations = 1;
427 if (advances % 3 == 0) {
428 BOOST_TEST(scheme1->
isActionRequired(CouplingScheme::Action::WriteCheckpoint));
431 BOOST_TEST(scheme1->
isActionRequired(CouplingScheme::Action::ReadCheckpoint));
432 BOOST_TEST(scheme1->
getTimeWindows() - 1 == (advances - (advances % 3)) / 3);
436 BOOST_TEST(advances == 30);
448 PRECICE_TEST(
"Participant0"_on(1_rank),
"Participant1"_on(1_rank),
"Participant2"_on(1_rank), Require::Events);
450 std::string configPath(_pathToTests +
"multi-solver-coupling-1.xml");
451 setupAndRunThreeSolverCoupling(configPath, context);
457 PRECICE_TEST(
"Participant0"_on(1_rank),
"Participant1"_on(1_rank),
"Participant2"_on(1_rank), Require::Events);
459 std::string configPath(_pathToTests +
"multi-solver-coupling-3.xml");
460 setupAndRunThreeSolverCoupling(configPath, context);
466 PRECICE_TEST(
"Participant0"_on(1_rank),
"Participant1"_on(1_rank),
"Participant2"_on(1_rank), Require::Events);
468 std::string configPath(_pathToTests +
"multi-solver-coupling-4.xml");
469 setupAndRunThreeSolverCoupling(configPath, context);
BOOST_AUTO_TEST_CASE(testDummySchemeCompositionExplicit2)
BOOST_AUTO_TEST_SUITE(PreProcess)
BOOST_AUTO_TEST_SUITE_END()
#define PRECICE_TEST(...)
Performs XML configuration of a participant.
Acts as one coupling scheme, but consists of several composed ones.
ChangedMeshes secondSynchronization() override
void initialize(double startTime, int startTimeWindow) final override
Initializes the coupling scheme and establishes a communication connection to the coupling partner.
void finalize() final override
Finalizes the coupling and disconnects communication.
bool isCouplingOngoing() const final override
Returns true, when the coupled simulation is still ongoing.
void secondExchange() override
bool addComputedTime(double timeToAdd) final override
Adds newly computed time. Has to be called before every advance.
void addCouplingScheme(const PtrCouplingScheme &scheme)
Adds another coupling scheme in parallel to this scheme.
void firstExchange() override
ChangedMeshes firstSynchronization(const ChangedMeshes &changes) override
Exchanges data and updates the state of the coupling scheme.
Configuration for coupling schemes.
const PtrCouplingScheme & getCouplingScheme(const std::string &participantName) const
Returns the configured coupling scheme.
virtual ChangedMeshes firstSynchronization(const ChangedMeshes &changes)=0
virtual bool addComputedTime(double timeToAdd)=0
Adds newly computed time. Has to be called before every advance.
virtual double getTime() const =0
Returns the currently computed time of the coupling scheme.
virtual void initialize(double startTime, int startTimeWindow)=0
Initializes the coupling scheme and establishes a communication connection to the coupling partner....
virtual ChangedMeshes secondSynchronization()=0
virtual void markActionFulfilled(Action action)=0
Tells the coupling scheme that the accessor has performed the given action.
virtual void secondExchange()=0
virtual double getNextTimeStepMaxSize() const =0
Returns the maximal size of the next time step to be computed.
virtual bool isTimeWindowComplete() const =0
Returns true, when the accessor can advance to the next time window.
virtual void finalize()=0
Finalizes the coupling and disconnects communication.
virtual bool isCouplingOngoing() const =0
Returns true, when the coupled simulation is still ongoing.
virtual int getTimeWindows() const =0
Returns the currently computed time windows of the coupling scheme.
virtual bool isActionRequired(Action action) const =0
Returns true, if the given action has to be performed by the accessor.
virtual bool hasDataBeenReceived() const =0
Returns true, if data has been exchanged in last call of advance().
virtual void firstExchange()=0
Used to test CompositionalCouplingScheme.
Configuration for communication channels between solvers.
bool isNamed(const std::string &name) const
Check whether this context has a given name.
std::string name
the name of the current participant
Represents an XML tag to be configured automatically.
contains implementations of coupling schemes for coupled simulations.
boost::test_tools::predicate_result equals(const std::vector< float > &VectorA, const std::vector< float > &VectorB, float tolerance)
equals to be used in tests. Compares two std::vectors using a given tolerance. Prints both operands o...
std::string getPathToSources()
Returns the base path to the sources.
XMLTag getRootTag()
Returns an XMLTag::Listener that does nothing on callbacks.
void configure(XMLTag &tag, const precice::xml::ConfigurationContext &context, std::string_view configurationFilename)
Configures the given configuration from file configurationFilename.
Main namespace of the precice library.
CompositionalCouplingSchemeFixture()
void runThreeSolverCoupling(PtrCouplingScheme cplScheme, const std::string &participantName, mesh::PtrMeshConfiguration meshConfig)
void connect(const std::string &participant0, const std::string &participant1, const std::string &localParticipant, m2n::PtrM2N communication) const
void setupAndRunThreeSolverCoupling(const std::string &configFilename, const precice::testing::TestContext &context)
Tightly coupled to the parameters of Participant()