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 time::Sample ssample{1, Eigen::VectorXd::Zero(mesh->nVertices())};
95 time::Sample vsample{3, Eigen::VectorXd::Zero(mesh->nVertices() * 3)};
97 if (participantName ==
std::string(
"Participant0")) {
98 mesh->data(
"Data0")->setSampleAtTime(0, ssample);
104 BOOST_REQUIRE(computedTime < 1.1);
110 mesh->data(
"Data0")->setSampleAtTime(computedTime + stepSize, ssample);
111 BOOST_TEST(cplScheme->
getTime() == computedTime);
113 BOOST_TEST(cplScheme->
getTime() == computedTime + stepSize);
122 computedTime += stepSize;
130 BOOST_TEST(computedTimesteps == 10);
134 }
else if (participantName ==
std::string(
"Participant1")) {
135 mesh->data(
"Data1")->setSampleAtTime(0, vsample);
141 BOOST_REQUIRE(computedTime < 1.1);
147 mesh->data(
"Data1")->setSampleAtTime(computedTime + stepSize, vsample);
148 BOOST_TEST(cplScheme->
getTime() == computedTime);
150 BOOST_TEST(cplScheme->
getTime() == computedTime + stepSize);
159 computedTime += stepSize;
167 BOOST_TEST(computedTimesteps == 10);
172 BOOST_TEST(participantName ==
std::string(
"Participant2"), participantName);
173 mesh->data(
"Data2")->setSampleAtTime(0, vsample);
179 BOOST_REQUIRE(computedTime < 1.1);
186 BOOST_TEST(cplScheme->
getTime() == computedTime);
188 BOOST_TEST(cplScheme->
getTime() == computedTime + stepSize);
197 computedTime += stepSize;
206 BOOST_TEST(computedTimesteps == 10);
218 BOOST_TEST(communication);
219 BOOST_TEST(not communication->isConnected());
220 useOnlyPrimaryCom(communication) =
true;
221 if (participant0 == localParticipant) {
222 communication->requestPrimaryRankConnection(participant1, participant0,
"");
224 BOOST_TEST(participant1 == localParticipant);
225 communication->acceptPrimaryRankConnection(participant1, participant0,
"");
237 int numberIterations = 1;
238 int maxTimeWindows = 10;
255 BOOST_TEST(advances == 10);
265 int numberIterations = 1;
266 int maxTimeWindows = 10;
288 BOOST_TEST(advances == 10);
299 int numberIterations = 1;
300 int maxTimeWindows = 10;
302 numberIterations = 2;
319 BOOST_TEST_CONTEXT(
"Advance Nr " << advances)
323 if (advances % 2 == 0) {
324 BOOST_TEST(scheme2->
isActionRequired(CouplingScheme::Action::WriteCheckpoint));
327 BOOST_TEST(scheme2->
isActionRequired(CouplingScheme::Action::ReadCheckpoint));
333 BOOST_TEST(advances == 20);
343 int numberIterations = 2;
344 int maxTimeWindows = 10;
346 numberIterations = 1;
360 if (advances % 2 == 0) {
361 BOOST_TEST(scheme1->
isActionRequired(CouplingScheme::Action::WriteCheckpoint));
364 BOOST_TEST(scheme1->
isActionRequired(CouplingScheme::Action::ReadCheckpoint));
369 BOOST_TEST(advances == 20);
379 int numberIterations = 1;
380 int maxTimeWindows = 10;
383 numberIterations = 3;
398 if (advances % 3 == 0) {
399 BOOST_TEST(scheme2->
isActionRequired(CouplingScheme::Action::WriteCheckpoint));
402 BOOST_TEST(scheme2->
isActionRequired(CouplingScheme::Action::ReadCheckpoint));
403 BOOST_TEST(scheme1->
getTimeWindows() - 1 == (advances + (3 - advances % 3)) / 3);
407 BOOST_TEST(advances == 30);
417 int numberIterations = 3;
418 int maxTimeWindows = 10;
420 numberIterations = 1;
434 if (advances % 3 == 0) {
435 BOOST_TEST(scheme1->
isActionRequired(CouplingScheme::Action::WriteCheckpoint));
438 BOOST_TEST(scheme1->
isActionRequired(CouplingScheme::Action::ReadCheckpoint));
439 BOOST_TEST(scheme1->
getTimeWindows() - 1 == (advances - (advances % 3)) / 3);
443 BOOST_TEST(advances == 30);
453PRECICE_TEST_SETUP("Participant0"_on(1_rank), "Participant1"_on(1_rank), "Participant2"_on(1_rank), Require::Events)
458 std::string configPath(_pathToTests +
"multi-solver-coupling-1.xml");
459 setupAndRunThreeSolverCoupling(configPath, context);
453PRECICE_TEST_SETUP("Participant0"_on(1_rank), "Participant1"_on(1_rank), "Participant2"_on(1_rank), Require::Events) {
…}
463PRECICE_TEST_SETUP(
"Participant0"_on(1_rank),
"Participant1"_on(1_rank),
"Participant2"_on(1_rank), Require::Events)
468 std::string configPath(_pathToTests +
"multi-solver-coupling-3.xml");
469 setupAndRunThreeSolverCoupling(configPath, context);
473PRECICE_TEST_SETUP(
"Participant0"_on(1_rank),
"Participant1"_on(1_rank),
"Participant2"_on(1_rank), Require::Events)
478 std::string configPath(_pathToTests +
"multi-solver-coupling-4.xml");
479 setupAndRunThreeSolverCoupling(configPath, context);
BOOST_AUTO_TEST_CASE(testDummySchemeCompositionExplicit2)
BOOST_AUTO_TEST_SUITE(PreProcess)
BOOST_AUTO_TEST_SUITE_END()
#define PRECICE_TEST_SETUP(...)
Creates and attaches a TestSetup to a Boost test case.
Performs XML configuration of a participant.
Acts as one coupling scheme, but consists of several composed ones.
ChangedMeshes secondSynchronization() override
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 initialize() final override
Initializes the coupling scheme and establishes a communication connection to the coupling partner.
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 void initialize()=0
Initializes the coupling scheme and establishes a communication connection to the coupling partner....
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 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 empty root tag with name "configuration".
std::string 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)
struct giving access to the impl of a befriended class or struct
Tightly coupled to the parameters of Participant()