46 using Eigen::VectorXd;
51 if (context.
size > 1) {
53 mesh::Vertex &v1 = mesh->createVertex(Eigen::Vector2d(0.0, 0.0));
54 mesh::Vertex &v2 = mesh->createVertex(Eigen::Vector2d(0.0, 1.0));
56 mesh->createEdge(v1, v2);
59 mesh::Vertex &v2 = mesh->createVertex(Eigen::Vector2d(0.0, 1.0));
60 mesh::Vertex &v3 = mesh->createVertex(Eigen::Vector2d(0.0, 2.0));
62 mesh->createEdge(v2, v3);
66 mesh::Vertex &v1 = mesh->createVertex(Eigen::Vector2d(0.0, 0.0));
67 mesh::Vertex &v2 = mesh->createVertex(Eigen::Vector2d(0.0, 1.0));
68 mesh::Vertex &v3 = mesh->createVertex(Eigen::Vector2d(0.0, 2.0));
70 mesh->createEdge(v1, v2);
71 mesh->createEdge(v2, v3);
75 using precice::testing::operator
""_dataID;
76 PtrData doubleData = mesh->createData(
"DoubleData", 1, 0_dataID);
77 PtrData vectorData = mesh->createData(
"VectorData", 2, 1_dataID);
78 auto & doubleValues = doubleData->values();
79 auto & vectorValues = vectorData->values();
80 mesh->allocateDataValues();
82 if (context.
size > 1) {
84 doubleValues(0) = 1.0;
85 doubleValues(1) = 2.0;
86 vectorValues(0) = 1.0;
87 vectorValues(1) = 2.0;
88 vectorValues(2) = 3.0;
89 vectorValues(3) = 4.0;
91 doubleValues(0) = 2.0;
92 doubleValues(1) = 3.0;
93 vectorValues(0) = 3.0;
94 vectorValues(1) = 4.0;
95 vectorValues(2) = 5.0;
96 vectorValues(3) = 6.0;
99 doubleValues(0) = 1.0;
100 doubleValues(1) = 2.0;
101 doubleValues(2) = 3.0;
102 vectorValues(0) = 1.0;
103 vectorValues(1) = 2.0;
104 vectorValues(2) = 3.0;
105 vectorValues(3) = 4.0;
106 vectorValues(4) = 5.0;
107 vectorValues(5) = 6.0;
110 std::string filename0(
"precice-WatchPointTest-timeseries-0.log");
112 bool isWatchpointClosest =
false;
116 Eigen::Vector2d pointToWatch0(watchPosition[0], watchPosition[1]);
121 isWatchpointClosest = watchpoint0.
isClosest();
126 if (context.
size > 1) {
128 doubleValues(0) = 2.0;
129 doubleValues(1) = 3.0;
130 vectorValues(0) = 2.0;
131 vectorValues(1) = 3.0;
132 vectorValues(2) = 4.0;
133 vectorValues(3) = 5.0;
135 doubleValues(0) = 3.0;
136 doubleValues(1) = 4.0;
137 vectorValues(0) = 4.0;
138 vectorValues(1) = 5.0;
139 vectorValues(2) = 6.0;
140 vectorValues(3) = 7.0;
143 doubleValues(0) = 2.0;
144 doubleValues(1) = 3.0;
145 doubleValues(2) = 4.0;
146 vectorValues(0) = 2.0;
147 vectorValues(1) = 3.0;
148 vectorValues(2) = 4.0;
149 vectorValues(3) = 5.0;
150 vectorValues(4) = 6.0;
151 vectorValues(5) = 7.0;
162 if (isWatchpointClosest) {
163 BOOST_TEST_CONTEXT(
"Validating watchpoint0")
165 auto result = readDoublesFromTXTFile(filename0, 6);
166 BOOST_TEST(result.size() == expected.
size());
167 for (
size_t i = 0; i < result.size(); ++i) {
168 BOOST_TEST_CONTEXT(
"entry index: " << i)
171 BOOST_TEST(equals(result.at(i), expected.
at(i)));
183 bool withEdge =
false;
186 0.0, 0.0, 1.0, 2.0, 3.0, 4.0,
187 1.0, 0.0, 1.0, 3.0, 4.0, 5.0,
188 2.0, 0.0, 1.0, 3.0, 4.0, 5.0};
195 bool withEdge =
true;
198 0.0, 0.0, 0.6, 1.6, 2.2, 3.2,
199 1.0, 0.0, 0.6, 2.6, 3.2, 4.2,
200 2.0, 0.0, 0.6, 2.6, 3.2, 4.2};
207 bool withEdge =
false;
210 0.0, 0.0, 2.0, 3.0, 5.0, 6.0,
211 1.0, 0.0, 2.0, 4.0, 6.0, 7.0,
212 2.0, 0.0, 2.0, 4.0, 6.0, 7.0};
219 bool withEdge =
true;
222 0.0, 0.0, 1.6, 2.6, 4.2, 5.2,
223 1.0, 0.0, 1.6, 3.6, 5.2, 6.2,
224 2.0, 0.0, 1.6, 3.6, 5.2, 6.2};
230 PRECICE_TEST(
""_on(2_ranks).setupIntraComm(), Require::Events);
231 bool withEdge =
false;
234 0.0, 0.0, 1.0, 2.0, 3.0, 4.0,
235 1.0, 0.0, 1.0, 3.0, 4.0, 5.0,
236 2.0, 0.0, 1.0, 3.0, 4.0, 5.0};
242 PRECICE_TEST(
""_on(2_ranks).setupIntraComm(), Require::Events);
243 bool withEdge =
true;
246 0.0, 0.0, 0.6, 1.6, 2.2, 3.2,
247 1.0, 0.0, 0.6, 2.6, 3.2, 4.2,
248 2.0, 0.0, 0.6, 2.6, 3.2, 4.2};
254 PRECICE_TEST(
""_on(2_ranks).setupIntraComm(), Require::Events);
255 bool withEdge =
false;
258 0.0, 0.0, 2.0, 3.0, 5.0, 6.0,
259 1.0, 0.0, 2.0, 4.0, 6.0, 7.0,
260 2.0, 0.0, 2.0, 4.0, 6.0, 7.0};
266 PRECICE_TEST(
""_on(2_ranks).setupIntraComm(), Require::Events);
267 bool withEdge =
true;
270 0.0, 0.0, 1.6, 2.6, 4.2, 5.2,
271 1.0, 0.0, 1.6, 3.6, 5.2, 6.2,
272 2.0, 0.0, 1.6, 3.6, 5.2, 6.2};
279 using namespace mesh;
280 using Eigen::VectorXd;
285 mesh::Vertex &v1 = mesh->createVertex(Eigen::Vector2d(0.0, 0.0));
286 mesh::Vertex &v2 = mesh->createVertex(Eigen::Vector2d(0.0, 1.0));
287 mesh::Vertex &v3 = mesh->createVertex(Eigen::Vector2d(1.0, 2.0));
288 mesh->createEdge(v1, v2);
290 PtrData doubleData = mesh->createData(
"DoubleData", 1, 0_dataID);
291 PtrData vectorData = mesh->createData(
"VectorData", 2, 1_dataID);
292 auto & doubleValues = doubleData->values();
293 auto & vectorValues = vectorData->values();
294 mesh->allocateDataValues();
298 doubleValues.setConstant(1.0);
299 doubleValues(2) = 2.0;
300 vectorValues.setConstant(1.0);
301 vectorValues(4) = 2.0;
302 vectorValues(5) = 2.0;
304 std::string filename0(
"precice-WatchPointTest-reinit-0.log");
305 std::string filename1(
"precice-WatchPointTest-reinit-1.log");
310 Eigen::Vector2d pointToWatch0(0.1, 0.5);
312 Eigen::Vector2d pointToWatch1(1.1, 0.5);
324 mesh::Vertex &v4 = mesh->createVertex(Eigen::Vector2d(1.0, 0.0));
325 mesh->createEdge(v3, v4);
326 mesh->index().clear();
327 mesh->allocateDataValues();
328 doubleValues.setConstant(1.0);
329 doubleValues(2) = 2.0;
330 doubleValues(3) = 2.0;
331 vectorValues.setConstant(1.0);
332 vectorValues(4) = 2.0;
333 vectorValues(5) = 2.0;
334 vectorValues(6) = 2.0;
335 vectorValues(7) = 2.0;
347 BOOST_TEST_CONTEXT(
"Validating watchpoint0")
349 auto result = readDoublesFromTXTFile(filename0, 6);
351 0.0, 0.0, 0.5, 1.0, 1.0, 1.0,
352 1.0, 0.0, 0.5, 1.0, 1.0, 1.0};
353 BOOST_TEST(result.size() == expected.size());
354 for (
size_t i = 0; i < result.size(); ++i) {
355 BOOST_TEST_CONTEXT(
"entry index: " << i)
358 BOOST_TEST(equals(result.at(i), expected.at(i)));
363 BOOST_TEST_CONTEXT(
"Validating watchpoint1")
365 auto result = readDoublesFromTXTFile(filename1, 6);
367 0.0, 0.0, 0.5, 1.0, 1.0, 1.0,
368 1.0, 1.0, 0.5, 2.0, 2.0, 2.0};
369 BOOST_TEST(result.size() == expected.size());
370 for (
size_t i = 0; i < result.size(); ++i) {
371 BOOST_TEST_CONTEXT(
"entry index: " << i)
374 BOOST_TEST(equals(result.at(i), expected.at(i)));
383 using namespace mesh;
384 using Eigen::VectorXd;
389 mesh::Vertex &v1 = mesh->createVertex(Eigen::Vector2d(0.0, 0.0));
390 mesh::Vertex &v2 = mesh->createVertex(Eigen::Vector2d(1.0, 0.0));
391 mesh::Vertex &v3 = mesh->createVertex(Eigen::Vector2d(0.0, 1.0));
392 mesh->createEdge(v1, v2);
393 mesh->createEdge(v2, v3);
394 mesh->createEdge(v3, v1);
395 mesh->createTriangle(v1, v2, v3);
397 PtrData doubleData = mesh->createData(
"DoubleData", 1, 0_dataID);
398 PtrData vectorData = mesh->createData(
"VectorData", 2, 1_dataID);
399 auto & doubleValues = doubleData->values();
400 auto & vectorValues = vectorData->values();
401 mesh->allocateDataValues();
404 doubleValues.setConstant(1.0);
405 doubleValues(2) = 2.0;
406 vectorValues.setConstant(1.0);
407 vectorValues(4) = 2.0;
408 vectorValues(5) = 2.0;
410 std::string filename0(
"precice-WatchPointTest-volumetric2d-0.log");
411 std::string filename1(
"precice-WatchPointTest-volumetric2d-1.log");
416 Eigen::Vector2d pointToWatch0(0.1, 0.5);
418 Eigen::Vector2d pointToWatch1(0.25, 0.25);
431 BOOST_TEST_CONTEXT(
"Validating watchpoint0")
433 auto result = readDoublesFromTXTFile(filename0, 6);
435 0.0, 0.1, 0.5, 1.5, 1.5, 1.5};
436 BOOST_TEST(result.size() == expected.size());
437 for (
size_t i = 0; i < result.size(); ++i) {
438 BOOST_TEST_CONTEXT(
"entry index: " << i)
441 BOOST_TEST(equals(result.at(i), expected.at(i)));
446 BOOST_TEST_CONTEXT(
"Validating watchpoint1")
448 auto result = readDoublesFromTXTFile(filename1, 6);
450 0.0, 0.25, 0.25, 1.25, 1.25, 1.25};
451 BOOST_TEST(result.size() == expected.size());
452 for (
size_t i = 0; i < result.size(); ++i) {
453 BOOST_TEST_CONTEXT(
"entry index: " << i)
456 BOOST_TEST(equals(result.at(i), expected.at(i)));
465 using namespace mesh;
466 using Eigen::VectorXd;
471 mesh::Vertex &v1 = mesh->createVertex(Eigen::Vector3d(0.0, 0.0, 0.0));
472 mesh::Vertex &v2 = mesh->createVertex(Eigen::Vector3d(1.0, 0.0, 0.0));
473 mesh::Vertex &v3 = mesh->createVertex(Eigen::Vector3d(0.0, 1.0, 0.0));
474 mesh::Vertex &v4 = mesh->createVertex(Eigen::Vector3d(0.0, 0.0, 1.0));
476 mesh->createTetrahedron(v1, v2, v3, v4);
478 PtrData doubleData = mesh->createData(
"DoubleData", 1, 0_dataID);
479 auto & doubleValues = doubleData->values();
480 mesh->allocateDataValues();
483 doubleValues(0) = 1.0;
484 doubleValues(1) = 2.0;
485 doubleValues(2) = 3.0;
486 doubleValues(3) = 4.0;
488 std::string filename0(
"precice-WatchPointTest-volumetric3d-0.log");
489 std::string filename1(
"precice-WatchPointTest-volumetric3d-1.log");
494 Eigen::Vector3d pointToWatch0(0.1, 0.5, 0.2);
496 Eigen::Vector3d pointToWatch1(0.25, 0.25, 0.25);
509 BOOST_TEST_CONTEXT(
"Validating watchpoint0")
511 auto result = readDoublesFromTXTFile(filename0, 5);
513 0.0, 0.1, 0.5, 0.2, 2.7};
514 BOOST_TEST(result.size() == expected.size());
515 for (
size_t i = 0; i < result.size(); ++i) {
516 BOOST_TEST_CONTEXT(
"entry index: " << i)
519 BOOST_TEST(equals(result.at(i), expected.at(i)));
524 BOOST_TEST_CONTEXT(
"Validating watchpoint1")
526 auto result = readDoublesFromTXTFile(filename1, 5);
528 0.0, 0.25, 0.25, 0.25, 2.5};
529 BOOST_TEST(result.size() == expected.size());
530 for (
size_t i = 0; i < result.size(); ++i) {
531 BOOST_TEST_CONTEXT(
"entry index: " << i)
534 BOOST_TEST(equals(result.at(i), expected.at(i)));
542 PRECICE_TEST(
""_on(4_ranks).setupIntraComm(), Require::Events);
543 using namespace mesh;
544 using Eigen::VectorXd;
549 switch (context.rank) {
551 mesh->createVertex(Eigen::Vector3d(0.0, 0.0, 0.0));
554 mesh::Vertex &v1 = mesh->createVertex(Eigen::Vector3d(0.0, 0.0, 0.0));
555 mesh::Vertex &v2 = mesh->createVertex(Eigen::Vector3d(0.0, 1.0, 0.0));
556 mesh->createEdge(v1, v2);
559 mesh::Vertex &v1 = mesh->createVertex(Eigen::Vector3d(0.0, 0.0, 0.0));
560 mesh::Vertex &v2 = mesh->createVertex(Eigen::Vector3d(0.0, 1.0, 0.0));
561 mesh::Vertex &v3 = mesh->createVertex(Eigen::Vector3d(0.0, 0.0, 1.0));
562 mesh->createTriangle(v1, v2, v3);
566 mesh::Vertex &v1 = mesh->createVertex(Eigen::Vector3d(0.0, 0.0, 0.0));
567 mesh::Vertex &v2 = mesh->createVertex(Eigen::Vector3d(1.0, 0.0, 0.0));
568 mesh::Vertex &v3 = mesh->createVertex(Eigen::Vector3d(0.0, 1.0, 0.0));
569 mesh::Vertex &v4 = mesh->createVertex(Eigen::Vector3d(0.0, 0.0, 1.0));
571 mesh->createTetrahedron(v1, v2, v3, v4);
575 PtrData doubleData = mesh->createData(
"DoubleData", 1, 0_dataID);
576 auto & doubleValues = doubleData->values();
577 mesh->allocateDataValues();
580 for (
int i = 0; i <= context.rank; ++i) {
581 doubleValues(i) = i + 1;
584 std::string filename0(
"precice-WatchPointTest-volumetricParallel-0.log");
590 Eigen::Vector3d pointToWatch0(0.1, 0.2, 0.3);
603 BOOST_TEST_CONTEXT(
"Validating watchpoint0")
605 auto result = readDoublesFromTXTFile(filename0, 5);
607 0.0, 0.1, 0.2, 0.3, 2.4};
608 BOOST_TEST(result.size() = expected.size());
609 for (
size_t i = 0; i < result.size(); ++i) {
610 BOOST_TEST_CONTEXT(
"entry index: " << i)
613 BOOST_TEST(equals(result.at(i), expected.at(i)));
int size
the size of the Communicator of the current participant
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...