preCICE v3.3.0
Loading...
Searching...
No Matches
ReceivedPartitionTest.cpp
Go to the documentation of this file.
1#ifndef PRECICE_NO_MPI
2
3#include <Eigen/Core>
4#include <algorithm>
5#include <map>
6#include <memory>
7#include <string>
8#include <vector>
9
10#include "com/Communication.hpp"
11#include "com/Extra.hpp"
12#include "com/SharedPointer.hpp"
15#include "fixtures.hpp"
17#include "m2n/M2N.hpp"
18#include "mapping/Mapping.hpp"
24#include "math/constants.hpp"
25#include "mesh/BoundingBox.hpp"
26#include "mesh/Data.hpp"
27#include "mesh/Mesh.hpp"
29#include "mesh/Vertex.hpp"
34#include "precice/impl/versions.hpp"
36#include "testing/Testing.hpp"
37#include "utils/assertion.hpp"
38
39namespace precice::mesh {
40class Edge;
41} // namespace precice::mesh
42
43using precice::Rank;
51
52BOOST_AUTO_TEST_SUITE(PartitionTests)
53BOOST_AUTO_TEST_SUITE(ReceivedPartitionTests)
54
55void createSolidzMesh2D(PtrMesh pSolidzMesh)
56{
57 int dimensions = 2;
58 BOOST_TEST(pSolidzMesh);
59 BOOST_TEST(pSolidzMesh->getDimensions() == dimensions);
60 Eigen::VectorXd position(dimensions);
61
62 position << 0.0, 0.0;
63 Vertex &v1 = pSolidzMesh->createVertex(position);
64 v1.setGlobalIndex(0);
65 position << 0.0, 1.95;
66 Vertex &v2 = pSolidzMesh->createVertex(position);
67 v2.setGlobalIndex(1);
68 position << 0.0, 2.1;
69 Vertex &v3 = pSolidzMesh->createVertex(position);
70 v3.setGlobalIndex(2);
71 position << 0.0, 4.5;
72 Vertex &v4 = pSolidzMesh->createVertex(position);
73 v4.setGlobalIndex(3);
74 position << 0.0, 5.95;
75 Vertex &v5 = pSolidzMesh->createVertex(position);
76 v5.setGlobalIndex(4);
77 position << 0.0, 6.1;
78 Vertex &v6 = pSolidzMesh->createVertex(position);
79 v6.setGlobalIndex(5);
80 pSolidzMesh->createEdge(v1, v2);
81 pSolidzMesh->createEdge(v2, v3);
82 pSolidzMesh->createEdge(v3, v4);
83 pSolidzMesh->createEdge(v4, v5);
84 pSolidzMesh->createEdge(v5, v6);
85 pSolidzMesh->computeBoundingBox();
86}
87
89{
90 int dimensions = 2;
91 BOOST_TEST(pSolidzMesh);
92 BOOST_TEST(pSolidzMesh->getDimensions() == dimensions);
93 Eigen::VectorXd position(dimensions);
94
95 position << 0.0, 0.0;
96 Vertex &v1 = pSolidzMesh->createVertex(position);
97 position << 0.0, 3.0;
98 Vertex &v2 = pSolidzMesh->createVertex(position);
99 position << 0.0, 6.0;
100 Vertex &v3 = pSolidzMesh->createVertex(position);
101 pSolidzMesh->createEdge(v1, v2);
102 pSolidzMesh->createEdge(v2, v3);
103 pSolidzMesh->computeBoundingBox();
104}
105
106void createNastinMesh2D(PtrMesh pNastinMesh, Rank rank)
107{
108 int dimensions = 2;
109 BOOST_TEST(pNastinMesh);
110 BOOST_TEST(pNastinMesh->getDimensions() == dimensions);
111
112 if (rank == 0) {
113 Eigen::VectorXd position(dimensions);
114 position << 0.0, 0.0;
115 pNastinMesh->createVertex(position);
116 position << 0.0, 2.0;
117 pNastinMesh->createVertex(position);
118 } else if (rank == 1) {
119 // not at interface
120 } else if (rank == 2) {
121 Eigen::VectorXd position(dimensions);
122 position << 0.0, 4.0;
123 pNastinMesh->createVertex(position);
124 position << 0.0, 6.0;
125 pNastinMesh->createVertex(position);
126 }
127 pNastinMesh->computeBoundingBox();
128}
129
130void createNastinMesh2D2(PtrMesh pNastinMesh, Rank rank)
131{
132 int dimensions = 2;
133 PRECICE_ASSERT(pNastinMesh.use_count() > 0);
134 PRECICE_ASSERT(pNastinMesh->getDimensions() == dimensions);
135
136 if (rank == 0) {
137 Eigen::VectorXd position(dimensions);
138 position << 0.10, 0.10;
139 pNastinMesh->createVertex(position);
140 position << 0.90, 0.90;
141 pNastinMesh->createVertex(position);
142 } else if (rank == 1) {
143 // not at interface
144 } else if (rank == 2) {
145
146 Eigen::VectorXd position(dimensions);
147 position << 2.1, 2.1;
148 pNastinMesh->createVertex(position);
149 position << 2.9, 2.9;
150 pNastinMesh->createVertex(position);
151 }
152 pNastinMesh->computeBoundingBox();
153}
154
156{
157 int dimensions = 3;
158 Eigen::VectorXd position(dimensions);
159 BOOST_TEST(pSolidzMesh);
160 BOOST_TEST(pSolidzMesh->getDimensions() == dimensions);
161
162 position << 0.0, 0.0, -0.1;
163 Vertex &v1 = pSolidzMesh->createVertex(position);
164 v1.setGlobalIndex(0);
165 position << -1.0, 0.0, 0.0;
166 Vertex &v2 = pSolidzMesh->createVertex(position);
167 v2.setGlobalIndex(1);
168 position << 1.0, 0.0, 0.0;
169 Vertex &v3 = pSolidzMesh->createVertex(position);
170 v3.setGlobalIndex(2);
171 position << 0.0, -1.0, 0.0;
172 Vertex &v4 = pSolidzMesh->createVertex(position);
173 v4.setGlobalIndex(3);
174 position << 0.0, 1.0, 0.0;
175 Vertex &v5 = pSolidzMesh->createVertex(position);
176 v5.setGlobalIndex(4);
177 Edge &e1 = pSolidzMesh->createEdge(v1, v2);
178 Edge &e2 = pSolidzMesh->createEdge(v2, v4);
179 Edge &e3 = pSolidzMesh->createEdge(v4, v1);
180 Edge &e4 = pSolidzMesh->createEdge(v1, v3);
181 Edge &e5 = pSolidzMesh->createEdge(v3, v5);
182 Edge &e6 = pSolidzMesh->createEdge(v5, v1);
183 pSolidzMesh->createTriangle(e1, e2, e3);
184 pSolidzMesh->createTriangle(e4, e5, e6);
185 pSolidzMesh->computeBoundingBox();
186}
187
188void createNastinMesh3D(PtrMesh pNastinMesh, Rank rank)
189{
190 int dimensions = 3;
191 BOOST_TEST(pNastinMesh);
192 BOOST_TEST(pNastinMesh->getDimensions() == dimensions);
193
194 if (rank == 0) { // Primary
195 Eigen::VectorXd position(dimensions);
196 position << -1.0, -1.0, 0.0;
197 pNastinMesh->createVertex(position);
198 position << -0.75, -0.75, 0.5;
199 pNastinMesh->createVertex(position);
200 } else if (rank == 1) { // SecondaryRank1
201 // secondary1 not at interface
202 } else if (rank == 2) { // Secondary rank 2
203 Eigen::VectorXd position(dimensions);
204 position << 0.0, 0.0, -1.0;
205 pNastinMesh->createVertex(position);
206 position << 0.5, 0.5, 0.0;
207 pNastinMesh->createVertex(position);
208 }
209 pNastinMesh->computeBoundingBox();
210}
211
212void createNastinMesh3D2(PtrMesh pNastinMesh, Rank rank)
213{
214 int dimensions = 3;
215 PRECICE_ASSERT(pNastinMesh.use_count() > 0);
216 PRECICE_ASSERT(pNastinMesh->getDimensions() == dimensions);
217
218 if (rank == 0) {
219 Eigen::VectorXd position(dimensions);
220 position << 0.10, 0.10, 0.1;
221 pNastinMesh->createVertex(position);
222 position << 0.90, 0.90, 0.9;
223 pNastinMesh->createVertex(position);
224 } else if (rank == 1) {
225 // not at interface
226 } else if (rank == 2) {
227
228 Eigen::VectorXd position(dimensions);
229 position << 2.1, 2.1, 2.1;
230 pNastinMesh->createVertex(position);
231 position << 2.9, 2.9, 2.1;
232 pNastinMesh->createVertex(position);
233 }
234 pNastinMesh->computeBoundingBox();
235}
236
237PRECICE_TEST_SETUP("Solid"_on(1_rank), "Fluid"_on(3_ranks).setupIntraComm(), Require::Events)
238BOOST_AUTO_TEST_CASE(RePartitionNNBroadcastFilter2D)
239{
240 PRECICE_TEST();
241 using namespace precice;
242 auto m2n = context.connectPrimaryRanks("Solid", "Fluid");
243
244 int dimensions = 2;
245 Eigen::VectorXd offset = Eigen::VectorXd::Zero(dimensions);
246
247 if (context.isNamed("Solid")) { // SOLIDZ
248 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
249 createSolidzMesh2D(pSolidzMesh);
250 BOOST_TEST(pSolidzMesh->nVertices() == 6);
251 ProvidedPartition part(pSolidzMesh);
252 part.addM2N(m2n);
253 part.communicate();
254 } else {
255 BOOST_TEST(context.isNamed("Fluid"));
256 PtrMesh pNastinMesh(new Mesh("NastinMesh", dimensions, testing::nextMeshID()));
257 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
258
259 mapping::PtrMapping boundingFromMapping = mapping::PtrMapping(
261 mapping::PtrMapping boundingToMapping = mapping::PtrMapping(
263 boundingFromMapping->setMeshes(pSolidzMesh, pNastinMesh);
264 boundingToMapping->setMeshes(pNastinMesh, pSolidzMesh);
265
266 createNastinMesh2D(pNastinMesh, context.rank);
267
268 double safetyFactor = 0.1;
269
270 ReceivedPartition part(pSolidzMesh, ReceivedPartition::ON_PRIMARY_RANK, safetyFactor);
271 part.addM2N(m2n);
272 part.addFromMapping(boundingFromMapping);
273 part.addToMapping(boundingToMapping);
274 part.communicate();
275 part.compute();
276
277 BOOST_TEST_CONTEXT(*pSolidzMesh)
278 {
279 // check if the sending and filtering worked right
280 if (context.isPrimary()) { // Primary
281 BOOST_TEST(pSolidzMesh->nVertices() == 2);
282 BOOST_TEST(pSolidzMesh->edges().size() == 1);
283 } else if (context.isRank(1)) { // SecondaryRank1
284 BOOST_TEST(pSolidzMesh->nVertices() == 0);
285 BOOST_TEST(pSolidzMesh->edges().size() == 0);
286 } else if (context.isRank(2)) { // Secondary rank 2
287 BOOST_TEST(pSolidzMesh->nVertices() == 2);
288 BOOST_TEST(pSolidzMesh->edges().size() == 1);
289 }
290 }
291 }
292}
293
294PRECICE_TEST_SETUP("Solid"_on(1_rank), "Fluid"_on(3_ranks).setupIntraComm(), Require::Events)
295BOOST_AUTO_TEST_CASE(RePartitionNNDoubleNode2D)
296{
297 PRECICE_TEST();
298 using namespace precice;
299 auto m2n = context.connectPrimaryRanks("Solid", "Fluid");
300
301 int dimensions = 2;
302 Eigen::VectorXd offset = Eigen::VectorXd::Zero(dimensions);
303
304 if (context.isNamed("Solid")) { // SOLIDZ
305 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
306 createSolidzMesh2DSmall(pSolidzMesh);
307 ProvidedPartition part(pSolidzMesh);
308 part.addM2N(m2n);
309 part.communicate();
310 } else {
311 BOOST_TEST(context.isNamed("Fluid"));
312 PtrMesh pNastinMesh(new Mesh("NastinMesh", dimensions, testing::nextMeshID()));
313 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
314
315 mapping::PtrMapping boundingFromMapping = mapping::PtrMapping(
317 mapping::PtrMapping boundingToMapping = mapping::PtrMapping(
319 boundingFromMapping->setMeshes(pSolidzMesh, pNastinMesh);
320 boundingToMapping->setMeshes(pNastinMesh, pSolidzMesh);
321
322 createNastinMesh2D(pNastinMesh, context.rank);
323
324 double safetyFactor = 0.5;
325
326 ReceivedPartition part(pSolidzMesh, ReceivedPartition::ON_SECONDARY_RANKS, safetyFactor);
327 part.addM2N(m2n);
328 part.addFromMapping(boundingFromMapping);
329 part.addToMapping(boundingToMapping);
330 part.communicate();
331 part.compute();
332
333 // check if the sending and filtering worked right
334 if (context.isPrimary()) { // Primary
335 BOOST_TEST(pSolidzMesh->nVertices() == 2);
336 BOOST_TEST(pSolidzMesh->edges().size() == 1);
337 } else if (context.isRank(1)) { // SecondaryRank1
338 BOOST_TEST(pSolidzMesh->nVertices() == 0);
339 BOOST_TEST(pSolidzMesh->edges().size() == 0);
340 } else if (context.isRank(2)) { // Secondary rank 2
341 BOOST_TEST(pSolidzMesh->nVertices() == 2);
342 BOOST_TEST(pSolidzMesh->edges().size() == 1);
343 }
344 }
345}
346
347PRECICE_TEST_SETUP("Solid"_on(1_rank), "Fluid"_on(3_ranks).setupIntraComm(), Require::Events)
348BOOST_AUTO_TEST_CASE(RePartitionNPPreFilterPostFilter2D)
349{
350 PRECICE_TEST();
351 using namespace precice;
352 auto m2n = context.connectPrimaryRanks("Solid", "Fluid");
353
354 int dimensions = 2;
355
356 if (context.isNamed("Solid")) { // SOLIDZ
357 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
358 createSolidzMesh2D(pSolidzMesh);
359 ProvidedPartition part(pSolidzMesh);
360 part.addM2N(m2n);
361 part.communicate();
362 } else {
363 BOOST_TEST(context.isNamed("Fluid"));
364 PtrMesh pNastinMesh(new Mesh("NastinMesh", dimensions, testing::nextMeshID()));
365 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
366
367 mapping::PtrMapping boundingFromMapping = mapping::PtrMapping(
369 mapping::PtrMapping boundingToMapping = mapping::PtrMapping(
371 boundingFromMapping->setMeshes(pSolidzMesh, pNastinMesh);
372 boundingToMapping->setMeshes(pNastinMesh, pSolidzMesh);
373
374 createNastinMesh2D(pNastinMesh, context.rank);
375
376 double safetyFactor = 0.1;
377 ReceivedPartition part(pSolidzMesh, ReceivedPartition::ON_PRIMARY_RANK, safetyFactor);
378 part.addM2N(m2n);
379 part.addFromMapping(boundingFromMapping);
380 part.addToMapping(boundingToMapping);
381 part.communicate();
382 part.compute();
383
384 BOOST_TEST_CONTEXT(*pSolidzMesh)
385 {
386 // check if the sending and filtering worked right
387 if (context.isPrimary()) { // Primary
388 BOOST_TEST(pSolidzMesh->nVertices() == 3);
389 BOOST_TEST(pSolidzMesh->edges().size() == 2);
390 } else if (context.isRank(1)) { // SecondaryRank1
391 BOOST_TEST(pSolidzMesh->nVertices() == 0);
392 BOOST_TEST(pSolidzMesh->edges().size() == 0);
393 } else if (context.isRank(2)) { // Secondary rank 2
394 BOOST_TEST(pSolidzMesh->nVertices() == 3);
395 BOOST_TEST(pSolidzMesh->edges().size() == 2);
396 }
397 }
398 }
399}
400
401#ifndef PRECICE_NO_PETSC
402PRECICE_TEST_SETUP("Solid"_on(1_rank), "Fluid"_on(3_ranks).setupIntraComm(), Require::Events, Require::PETSc)
403BOOST_AUTO_TEST_CASE(RePartitionRBFGlobal2D)
404{
405 PRECICE_TEST();
406 using namespace precice;
407 auto m2n = context.connectPrimaryRanks("Solid", "Fluid");
408
409 int dimensions = 2;
410
411 if (context.isNamed("Solid")) { // SOLIDZ
412 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
413 createSolidzMesh2D(pSolidzMesh);
414 ProvidedPartition part(pSolidzMesh);
415 part.addM2N(m2n);
416 part.communicate();
417 } else {
418 BOOST_TEST(context.isNamed("Fluid"));
419 PtrMesh pNastinMesh(new Mesh("NastinMesh", dimensions, testing::nextMeshID()));
420 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
421
422 mapping::PtrMapping boundingFromMapping = mapping::PtrMapping(
424 mapping::ThinPlateSplines(), {{false, false, false}}));
425 mapping::PtrMapping boundingToMapping = mapping::PtrMapping(
427 boundingFromMapping->setMeshes(pSolidzMesh, pNastinMesh);
428 boundingToMapping->setMeshes(pNastinMesh, pSolidzMesh);
429
430 createNastinMesh2D(pNastinMesh, context.rank);
431
432 double safetyFactor = 20.0;
433 ReceivedPartition part(pSolidzMesh, ReceivedPartition::NO_FILTER, safetyFactor);
434 part.addM2N(m2n);
435 part.addFromMapping(boundingFromMapping);
436 part.addToMapping(boundingToMapping);
437 part.communicate();
438 part.compute();
439
440 BOOST_TEST_CONTEXT(*pSolidzMesh)
441 {
442 BOOST_TEST(pSolidzMesh->getVertexOffsets().size() == 3);
443 BOOST_TEST(pSolidzMesh->getVertexOffsets().at(0) == 6);
444 BOOST_TEST(pSolidzMesh->getVertexOffsets().at(1) == 6);
445 BOOST_TEST(pSolidzMesh->getVertexOffsets().at(2) == 12);
446 BOOST_TEST(pSolidzMesh->getGlobalNumberOfVertices() == 6);
447
448 // check if the sending and filtering worked right
449 if (context.isPrimary()) { // Primary
450 BOOST_TEST(pSolidzMesh->nVertices() == 6);
451 BOOST_TEST(pSolidzMesh->edges().size() == 5);
452 BOOST_TEST(pSolidzMesh->vertex(0).isOwner() == true);
453 BOOST_TEST(pSolidzMesh->vertex(1).isOwner() == true);
454 BOOST_TEST(pSolidzMesh->vertex(2).isOwner() == true);
455 BOOST_TEST(pSolidzMesh->vertex(3).isOwner() == false);
456 BOOST_TEST(pSolidzMesh->vertex(4).isOwner() == false);
457 BOOST_TEST(pSolidzMesh->vertex(5).isOwner() == false);
458 BOOST_TEST(pSolidzMesh->vertex(0).getGlobalIndex() == 0);
459 BOOST_TEST(pSolidzMesh->vertex(1).getGlobalIndex() == 1);
460 BOOST_TEST(pSolidzMesh->vertex(2).getGlobalIndex() == 2);
461 BOOST_TEST(pSolidzMesh->vertex(3).getGlobalIndex() == 3);
462 BOOST_TEST(pSolidzMesh->vertex(4).getGlobalIndex() == 4);
463 BOOST_TEST(pSolidzMesh->vertex(5).getGlobalIndex() == 5);
464 } else if (context.isRank(1)) { // Secondary rank 2
465 BOOST_TEST(pSolidzMesh->nVertices() == 0);
466 BOOST_TEST(pSolidzMesh->edges().size() == 0);
467 } else if (context.isRank(2)) { // Secondary rank 3
468 BOOST_TEST(pSolidzMesh->nVertices() == 6);
469 BOOST_TEST(pSolidzMesh->edges().size() == 5);
470 BOOST_TEST(pSolidzMesh->vertex(0).isOwner() == false);
471 BOOST_TEST(pSolidzMesh->vertex(1).isOwner() == false);
472 BOOST_TEST(pSolidzMesh->vertex(2).isOwner() == false);
473 BOOST_TEST(pSolidzMesh->vertex(3).isOwner() == true);
474 BOOST_TEST(pSolidzMesh->vertex(4).isOwner() == true);
475 BOOST_TEST(pSolidzMesh->vertex(5).isOwner() == true);
476 BOOST_TEST(pSolidzMesh->vertex(0).getGlobalIndex() == 0);
477 BOOST_TEST(pSolidzMesh->vertex(1).getGlobalIndex() == 1);
478 BOOST_TEST(pSolidzMesh->vertex(2).getGlobalIndex() == 2);
479 BOOST_TEST(pSolidzMesh->vertex(3).getGlobalIndex() == 3);
480 BOOST_TEST(pSolidzMesh->vertex(4).getGlobalIndex() == 4);
481 BOOST_TEST(pSolidzMesh->vertex(5).getGlobalIndex() == 5);
482 }
483 }
484 }
485}
486
487PRECICE_TEST_SETUP("Solid"_on(1_rank), "Fluid"_on(3_ranks).setupIntraComm(), Require::Events, Require::PETSc)
488BOOST_AUTO_TEST_CASE(RePartitionRBFLocal2D1)
489{
490 PRECICE_TEST();
491 using namespace precice;
492 auto m2n = context.connectPrimaryRanks("Solid", "Fluid");
493
494 int dimensions = 2;
495
496 if (context.isNamed("Solid")) { // SOLIDZ
497 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
498 createSolidzMesh2D(pSolidzMesh);
499 ProvidedPartition part(pSolidzMesh);
500 part.addM2N(m2n);
501 part.communicate();
502 } else {
503 BOOST_TEST(context.isNamed("Fluid"));
504 PtrMesh pNastinMesh(new Mesh("NastinMesh", dimensions, testing::nextMeshID()));
505 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
506
507 double supportRadius = 0.25;
508
509 mapping::PtrMapping boundingFromMapping = mapping::PtrMapping(
511 mapping::CompactThinPlateSplinesC2(supportRadius), {{false, false, false}}));
512 mapping::PtrMapping boundingToMapping = mapping::PtrMapping(
514 boundingFromMapping->setMeshes(pSolidzMesh, pNastinMesh);
515 boundingToMapping->setMeshes(pNastinMesh, pSolidzMesh);
516
517 createNastinMesh2D(pNastinMesh, context.rank);
518
519 double safetyFactor = 20.0;
520 ReceivedPartition part(pSolidzMesh, ReceivedPartition::NO_FILTER, safetyFactor);
521 part.addM2N(m2n);
522 part.addFromMapping(boundingFromMapping);
523 part.addToMapping(boundingToMapping);
524 part.communicate();
525 part.compute();
526
527 BOOST_TEST_CONTEXT(*pSolidzMesh)
528 {
529 BOOST_TEST(pSolidzMesh->getVertexOffsets().size() == 3);
530 BOOST_TEST(pSolidzMesh->getVertexOffsets().at(0) == 3);
531 BOOST_TEST(pSolidzMesh->getVertexOffsets().at(1) == 3);
532 BOOST_TEST(pSolidzMesh->getVertexOffsets().at(2) == 6);
533 BOOST_TEST(pSolidzMesh->getGlobalNumberOfVertices() == 6);
534
535 // check if the sending and filtering worked right
536 if (context.isPrimary()) { // Primary
537 BOOST_TEST(pSolidzMesh->nVertices() == 3);
538 BOOST_TEST(pSolidzMesh->edges().size() == 2);
539 BOOST_TEST(pSolidzMesh->vertex(0).isOwner() == true);
540 BOOST_TEST(pSolidzMesh->vertex(1).isOwner() == true);
541 BOOST_TEST(pSolidzMesh->vertex(2).isOwner() == true);
542 BOOST_TEST(pSolidzMesh->vertex(0).getGlobalIndex() == 0);
543 BOOST_TEST(pSolidzMesh->vertex(1).getGlobalIndex() == 1);
544 BOOST_TEST(pSolidzMesh->vertex(2).getGlobalIndex() == 2);
545 } else if (context.isRank(1)) { // Secondary rank 2
546 BOOST_TEST(pSolidzMesh->nVertices() == 0);
547 BOOST_TEST(pSolidzMesh->edges().size() == 0);
548 } else if (context.isRank(2)) { // Secondary rank 3
549 BOOST_TEST(pSolidzMesh->nVertices() == 3);
550 BOOST_TEST(pSolidzMesh->edges().size() == 2);
551 BOOST_TEST(pSolidzMesh->vertex(0).isOwner() == true);
552 BOOST_TEST(pSolidzMesh->vertex(1).isOwner() == true);
553 BOOST_TEST(pSolidzMesh->vertex(2).isOwner() == true);
554 BOOST_TEST(pSolidzMesh->vertex(0).getGlobalIndex() == 3);
555 BOOST_TEST(pSolidzMesh->vertex(1).getGlobalIndex() == 4);
556 BOOST_TEST(pSolidzMesh->vertex(2).getGlobalIndex() == 5);
557 }
558 }
559 }
560}
561
562PRECICE_TEST_SETUP("Solid"_on(1_rank), "Fluid"_on(3_ranks).setupIntraComm(), Require::Events, Require::PETSc)
563BOOST_AUTO_TEST_CASE(RePartitionRBFLocal2D2)
564{
565 PRECICE_TEST();
566 using namespace precice;
567 auto m2n = context.connectPrimaryRanks("Solid", "Fluid");
568
569 int dimensions = 2;
570
571 if (context.isNamed("Solid")) { // SOLIDZ
572 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
573 createSolidzMesh2D(pSolidzMesh);
574 ProvidedPartition part(pSolidzMesh);
575 part.addM2N(m2n);
576 part.communicate();
577 } else {
578 BOOST_TEST(context.isNamed("Fluid"));
579 PtrMesh pNastinMesh(new Mesh("NastinMesh", dimensions, testing::nextMeshID()));
580 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
581
582 double supportRadius = 2.45;
583
584 mapping::PtrMapping boundingFromMapping = mapping::PtrMapping(
586 mapping::CompactThinPlateSplinesC2(supportRadius), {{false, false, false}}));
587 mapping::PtrMapping boundingToMapping = mapping::PtrMapping(
589 boundingFromMapping->setMeshes(pSolidzMesh, pNastinMesh);
590 boundingToMapping->setMeshes(pNastinMesh, pSolidzMesh);
591
592 createNastinMesh2D(pNastinMesh, context.rank);
593
594 double safetyFactor = 20.0;
595 ReceivedPartition part(pSolidzMesh, ReceivedPartition::NO_FILTER, safetyFactor);
596 part.addM2N(m2n);
597 part.addFromMapping(boundingFromMapping);
598 part.addToMapping(boundingToMapping);
599 part.communicate();
600 part.compute();
601
602 BOOST_TEST_CONTEXT(*pSolidzMesh)
603 {
604 BOOST_TEST(pSolidzMesh->getVertexOffsets().size() == 3);
605 BOOST_TEST(pSolidzMesh->getVertexOffsets().at(0) == 4);
606 BOOST_TEST(pSolidzMesh->getVertexOffsets().at(1) == 4);
607 BOOST_TEST(pSolidzMesh->getVertexOffsets().at(2) == 9);
608 BOOST_TEST(pSolidzMesh->getGlobalNumberOfVertices() == 6);
609
610 // check if the sending and filtering worked right
611 if (context.isPrimary()) { // Primary
612 BOOST_TEST(pSolidzMesh->nVertices() == 4);
613 BOOST_TEST(pSolidzMesh->edges().size() == 3);
614 BOOST_TEST(pSolidzMesh->vertex(0).isOwner() == true);
615 BOOST_TEST(pSolidzMesh->vertex(1).isOwner() == true);
616 BOOST_TEST(pSolidzMesh->vertex(2).isOwner() == true);
617 BOOST_TEST(pSolidzMesh->vertex(3).isOwner() == false);
618 BOOST_TEST(pSolidzMesh->vertex(0).getGlobalIndex() == 0);
619 BOOST_TEST(pSolidzMesh->vertex(1).getGlobalIndex() == 1);
620 BOOST_TEST(pSolidzMesh->vertex(2).getGlobalIndex() == 2);
621 BOOST_TEST(pSolidzMesh->vertex(3).getGlobalIndex() == 3);
622 } else if (context.isRank(1)) { // Secondary rank 2
623 BOOST_TEST(pSolidzMesh->nVertices() == 0);
624 BOOST_TEST(pSolidzMesh->edges().size() == 0);
625 } else if (context.isRank(2)) { // Secondary rank 3
626 BOOST_TEST(pSolidzMesh->nVertices() == 5);
627 BOOST_TEST(pSolidzMesh->edges().size() == 4);
628 BOOST_TEST(pSolidzMesh->vertex(0).isOwner() == false);
629 BOOST_TEST(pSolidzMesh->vertex(1).isOwner() == false);
630 BOOST_TEST(pSolidzMesh->vertex(2).isOwner() == true);
631 BOOST_TEST(pSolidzMesh->vertex(3).isOwner() == true);
632 BOOST_TEST(pSolidzMesh->vertex(4).isOwner() == true);
633 BOOST_TEST(pSolidzMesh->vertex(0).getGlobalIndex() == 1);
634 BOOST_TEST(pSolidzMesh->vertex(1).getGlobalIndex() == 2);
635 BOOST_TEST(pSolidzMesh->vertex(2).getGlobalIndex() == 3);
636 BOOST_TEST(pSolidzMesh->vertex(3).getGlobalIndex() == 4);
637 BOOST_TEST(pSolidzMesh->vertex(4).getGlobalIndex() == 5);
638 }
639 }
640 }
641}
642
643PRECICE_TEST_SETUP("Solid"_on(1_rank), "Fluid"_on(3_ranks).setupIntraComm(), Require::Events, Require::PETSc)
644BOOST_AUTO_TEST_CASE(RePartitionRBFLocal3D)
645{
646 PRECICE_TEST();
647 using namespace precice;
648 auto m2n = context.connectPrimaryRanks("Solid", "Fluid");
649
650 int dimensions = 3;
651
652 if (context.isNamed("Solid")) { // SOLIDZ
653 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
654 createSolidzMesh3D(pSolidzMesh);
655 ProvidedPartition part(pSolidzMesh);
656 part.addM2N(m2n);
657 part.communicate();
658 } else {
659 BOOST_TEST(context.isNamed("Fluid"));
660 PtrMesh pNastinMesh(new Mesh("NastinMesh", dimensions, testing::nextMeshID()));
661 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
662
663 double supportRadius1 = 1.2;
664 double supportRadius2 = 0.2;
665
666 mapping::PtrMapping boundingFromMapping = mapping::PtrMapping(
668 mapping::CompactThinPlateSplinesC2(supportRadius1), {{false, false, false}}));
669 mapping::PtrMapping boundingToMapping = mapping::PtrMapping(
671 mapping::CompactThinPlateSplinesC2(supportRadius2), {{false, false, false}}));
672 boundingFromMapping->setMeshes(pSolidzMesh, pNastinMesh);
673 boundingToMapping->setMeshes(pNastinMesh, pSolidzMesh);
674
675 createNastinMesh3D(pNastinMesh, context.rank);
676
677 double safetyFactor = 20.0;
678 ReceivedPartition part(pSolidzMesh, ReceivedPartition::NO_FILTER, safetyFactor);
679 part.addM2N(m2n);
680 part.addFromMapping(boundingFromMapping);
681 part.addToMapping(boundingToMapping);
682 part.communicate();
683 part.compute();
684
685 BOOST_TEST_CONTEXT(*pSolidzMesh)
686 {
687 BOOST_TEST(pSolidzMesh->getVertexOffsets().size() == 3);
688 BOOST_TEST(pSolidzMesh->getVertexOffsets().at(0) == 5);
689 BOOST_TEST(pSolidzMesh->getVertexOffsets().at(1) == 5);
690 BOOST_TEST(pSolidzMesh->getVertexOffsets().at(2) == 10);
691 BOOST_TEST(pSolidzMesh->getGlobalNumberOfVertices() == 5);
692
693 // check if the sending and filtering worked right
694 if (context.isPrimary()) { // Primary
695 BOOST_TEST(pSolidzMesh->nVertices() == 5);
696 BOOST_TEST(pSolidzMesh->edges().size() == 6);
697 BOOST_TEST(pSolidzMesh->triangles().size() == 2);
698 BOOST_TEST(pSolidzMesh->vertex(0).isOwner() == true);
699 BOOST_TEST(pSolidzMesh->vertex(1).isOwner() == true);
700 BOOST_TEST(pSolidzMesh->vertex(2).isOwner() == false);
701 BOOST_TEST(pSolidzMesh->vertex(3).isOwner() == false);
702 BOOST_TEST(pSolidzMesh->vertex(4).isOwner() == false);
703 BOOST_TEST(pSolidzMesh->vertex(0).getGlobalIndex() == 0);
704 BOOST_TEST(pSolidzMesh->vertex(1).getGlobalIndex() == 1);
705 BOOST_TEST(pSolidzMesh->vertex(2).getGlobalIndex() == 2);
706 BOOST_TEST(pSolidzMesh->vertex(3).getGlobalIndex() == 3);
707 BOOST_TEST(pSolidzMesh->vertex(4).getGlobalIndex() == 4);
708 } else if (context.isRank(1)) { // Secondary rank 2
709 BOOST_TEST(pSolidzMesh->nVertices() == 0);
710 BOOST_TEST(pSolidzMesh->edges().size() == 0);
711 BOOST_TEST(pSolidzMesh->triangles().size() == 0);
712 } else if (context.isRank(2)) { // Secondary rank 3
713 BOOST_TEST(pSolidzMesh->nVertices() == 5);
714 BOOST_TEST(pSolidzMesh->edges().size() == 6);
715 BOOST_TEST(pSolidzMesh->triangles().size() == 2);
716 BOOST_TEST(pSolidzMesh->vertex(0).isOwner() == false);
717 BOOST_TEST(pSolidzMesh->vertex(1).isOwner() == false);
718 BOOST_TEST(pSolidzMesh->vertex(2).isOwner() == true);
719 BOOST_TEST(pSolidzMesh->vertex(3).isOwner() == true);
720 BOOST_TEST(pSolidzMesh->vertex(4).isOwner() == true);
721 BOOST_TEST(pSolidzMesh->vertex(0).getGlobalIndex() == 0);
722 BOOST_TEST(pSolidzMesh->vertex(1).getGlobalIndex() == 1);
723 BOOST_TEST(pSolidzMesh->vertex(2).getGlobalIndex() == 2);
724 BOOST_TEST(pSolidzMesh->vertex(3).getGlobalIndex() == 3);
725 BOOST_TEST(pSolidzMesh->vertex(4).getGlobalIndex() == 4);
726 }
727 }
728 }
729}
730
731#endif // PRECICE_NO_PETSC
732
733PRECICE_TEST_SETUP("Fluid"_on(3_ranks).setupIntraComm(), "Solid"_on(1_rank), Require::Events)
734BOOST_AUTO_TEST_CASE(RePartitionNPBroadcastFilter3D)
735{
736 PRECICE_TEST();
737 using namespace precice;
738 auto m2n = context.connectPrimaryRanks("Solid", "Fluid");
739
740 int dimensions = 3;
741
742 if (context.isNamed("Solid")) { // SOLIDZ
743 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
744 createSolidzMesh3D(pSolidzMesh);
745 ProvidedPartition part(pSolidzMesh);
746 part.addM2N(m2n);
747 part.communicate();
748 } else {
749 BOOST_TEST(context.isNamed("Fluid"));
750 PtrMesh pNastinMesh(new Mesh("NastinMesh", dimensions, testing::nextMeshID()));
751 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
752
753 mapping::PtrMapping boundingFromMapping = mapping::PtrMapping(
755 mapping::PtrMapping boundingToMapping = mapping::PtrMapping(
757 boundingFromMapping->setMeshes(pSolidzMesh, pNastinMesh);
758 boundingToMapping->setMeshes(pNastinMesh, pSolidzMesh);
759
760 createNastinMesh3D(pNastinMesh, context.rank);
761
762 double safetyFactor = 20.0;
763 ReceivedPartition part(pSolidzMesh, ReceivedPartition::ON_PRIMARY_RANK, safetyFactor);
764 part.addM2N(m2n);
765 part.addFromMapping(boundingFromMapping);
766 part.addToMapping(boundingToMapping);
767 part.communicate();
768 part.compute();
769
770 // check if the sending and filtering worked right
771 if (context.isPrimary()) { // Primary
772 BOOST_TEST(pSolidzMesh->nVertices() == 2);
773 BOOST_TEST(pSolidzMesh->edges().size() == 1);
774 BOOST_TEST(pSolidzMesh->triangles().size() == 0);
775 } else if (context.isRank(1)) { // SecondaryRank1
776 BOOST_TEST(pSolidzMesh->nVertices() == 0);
777 BOOST_TEST(pSolidzMesh->edges().size() == 0);
778 BOOST_TEST(pSolidzMesh->triangles().size() == 0);
779 } else if (context.isRank(2)) { // Secondary rank 2
780 BOOST_TEST(pSolidzMesh->nVertices() == 3);
781 BOOST_TEST(pSolidzMesh->edges().size() == 3);
782 BOOST_TEST(pSolidzMesh->triangles().size() == 1);
783 }
784 }
785}
786
787PRECICE_TEST_SETUP("Solid"_on(1_rank), "Fluid"_on(3_ranks).setupIntraComm(), Require::Events)
788BOOST_AUTO_TEST_CASE(TestRepartitionAndDistribution2D)
789{
790 PRECICE_TEST();
791 using namespace precice;
792 auto m2n = context.connectPrimaryRanks("Solid", "Fluid");
793
794 int dimensions = 2;
795
796 if (context.isNamed("Solid")) { // SOLIDZ
797 PtrMesh pMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
798
799 Eigen::VectorXd position(dimensions);
800 position << 0.0, 0.0;
801 pMesh->createVertex(position);
802 position << 1.0, 0.0;
803 pMesh->createVertex(position);
804 position << 2.0, 0.0;
805 pMesh->createVertex(position);
806
807 pMesh->computeBoundingBox();
808
809 ProvidedPartition part(pMesh);
810 part.addM2N(m2n);
811 part.communicate();
812
813 } else {
814 BOOST_TEST(context.isNamed("Fluid"));
815 PtrMesh pMesh(new Mesh("NastinMesh", dimensions, testing::nextMeshID()));
816 PtrMesh pOtherMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
817
818 mapping::PtrMapping boundingFromMapping = mapping::PtrMapping(
820 boundingFromMapping->setMeshes(pMesh, pOtherMesh);
821
822 if (context.isPrimary()) { // Primary
823 Eigen::VectorXd position(dimensions);
824 position << 0.0, 0.0;
825 pOtherMesh->createVertex(position);
826 position << 0.8, 0.0;
827 pOtherMesh->createVertex(position);
828 } else if (context.isRank(1)) { // Secondary rank 2
829 Eigen::VectorXd position(dimensions);
830 position << 1.0, 0.0;
831 pOtherMesh->createVertex(position);
832 position << 1.2, 0.0;
833 pOtherMesh->createVertex(position);
834 } else if (context.isRank(2)) { // Secondary rank 3
835 // no vertices
836 }
837
838 pOtherMesh->computeBoundingBox();
839
840 double safetyFactor = 20.0;
841 ReceivedPartition part(pMesh, ReceivedPartition::ON_PRIMARY_RANK, safetyFactor);
842 part.addM2N(m2n);
843 part.addFromMapping(boundingFromMapping);
844 part.communicate();
845 part.compute();
846
847 BOOST_TEST(pMesh->getVertexOffsets().size() == 3);
848 BOOST_TEST(pMesh->getVertexOffsets().at(0) == 2);
849 BOOST_TEST(pMesh->getVertexOffsets().at(1) == 3);
850 BOOST_TEST(pMesh->getVertexOffsets().at(2) == 3);
851
852 if (context.isPrimary()) { // Primary
853 BOOST_TEST(pMesh->getVertexDistribution().at(0).size() == 2);
854 BOOST_TEST(pMesh->getVertexDistribution().at(1).size() == 1);
855 BOOST_TEST(pMesh->getVertexDistribution().at(2).size() == 0);
856 BOOST_TEST(pMesh->getVertexDistribution().at(0).at(0) == 0);
857 BOOST_TEST(pMesh->getVertexDistribution().at(0).at(1) == 1);
858 BOOST_TEST(pMesh->getVertexDistribution().at(1).at(0) == 1);
859 BOOST_TEST(pMesh->nVertices() == 2);
860 BOOST_TEST(pMesh->vertex(0).getGlobalIndex() == 0);
861 BOOST_TEST(pMesh->vertex(1).getGlobalIndex() == 1);
862 BOOST_TEST(pMesh->vertex(0).isOwner() == true);
863 BOOST_TEST(pMesh->vertex(1).isOwner() == false);
864 } else if (context.isRank(1)) { // Secondary rank 2
865 BOOST_TEST(pMesh->nVertices() == 1);
866 BOOST_TEST(pMesh->vertex(0).getGlobalIndex() == 1);
867 BOOST_TEST(pMesh->vertex(0).isOwner() == true);
868 } else if (context.isRank(2)) { // Secondary rank 3
869 BOOST_TEST(pMesh->nVertices() == 0);
870 }
871 }
872}
873
874PRECICE_TEST_SETUP("Fluid"_on(1_rank), "Solid"_on(1_rank), Require::Events)
875BOOST_AUTO_TEST_CASE(ProvideAndReceiveCouplingMode)
876{
877 PRECICE_TEST();
878 using namespace precice;
879 auto m2n = context.connectPrimaryRanks("Solid", "Fluid");
880
881 int dimensions = 2;
882
883 if (context.isNamed("Solid")) {
884 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
885 createSolidzMesh2D(pSolidzMesh);
886 ProvidedPartition part(pSolidzMesh);
887 part.addM2N(m2n);
888 part.communicate();
889 part.compute();
890
891 BOOST_TEST(pSolidzMesh->getGlobalNumberOfVertices() == 6);
892 BOOST_TEST(pSolidzMesh->nVertices() == 6);
893 BOOST_TEST(pSolidzMesh->edges().size() == 5);
894 BOOST_TEST(pSolidzMesh->getVertexOffsets().size() == 1);
895 BOOST_TEST(pSolidzMesh->getVertexOffsets().at(0) == 6);
896 BOOST_TEST(pSolidzMesh->vertex(0).getGlobalIndex() == 0);
897 BOOST_TEST(pSolidzMesh->vertex(1).getGlobalIndex() == 1);
898 BOOST_TEST(pSolidzMesh->vertex(2).getGlobalIndex() == 2);
899 BOOST_TEST(pSolidzMesh->vertex(3).getGlobalIndex() == 3);
900 BOOST_TEST(pSolidzMesh->vertex(4).getGlobalIndex() == 4);
901 BOOST_TEST(pSolidzMesh->vertex(5).getGlobalIndex() == 5);
902 BOOST_TEST(pSolidzMesh->vertex(0).isOwner() == true);
903 BOOST_TEST(pSolidzMesh->vertex(1).isOwner() == true);
904 BOOST_TEST(pSolidzMesh->vertex(2).isOwner() == true);
905 BOOST_TEST(pSolidzMesh->vertex(3).isOwner() == true);
906 BOOST_TEST(pSolidzMesh->vertex(4).isOwner() == true);
907 BOOST_TEST(pSolidzMesh->vertex(5).isOwner() == true);
908 } else {
909 BOOST_TEST(context.isNamed("Fluid"));
910 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
911
912 PtrMesh pOtherMesh(new Mesh("OtherMesh", dimensions, testing::nextMeshID()));
913 mapping::PtrMapping boundingFromMapping = mapping::PtrMapping(
915 boundingFromMapping->setMeshes(pSolidzMesh, pOtherMesh);
916
917 double safetyFactor = 0.1;
918 ReceivedPartition part(pSolidzMesh, ReceivedPartition::ON_PRIMARY_RANK, safetyFactor);
919 part.addFromMapping(boundingFromMapping);
920 part.addM2N(m2n);
921 part.communicate();
922 part.compute();
923
924 BOOST_TEST(pSolidzMesh->getGlobalNumberOfVertices() == 6);
925 BOOST_TEST(pSolidzMesh->nVertices() == 6);
926 BOOST_TEST(pSolidzMesh->edges().size() == 5);
927 BOOST_TEST(pSolidzMesh->getVertexOffsets().size() == 1);
928 BOOST_TEST(pSolidzMesh->getVertexOffsets().at(0) == 6);
929 BOOST_TEST(pSolidzMesh->vertex(0).getGlobalIndex() == 0);
930 BOOST_TEST(pSolidzMesh->vertex(1).getGlobalIndex() == 1);
931 BOOST_TEST(pSolidzMesh->vertex(2).getGlobalIndex() == 2);
932 BOOST_TEST(pSolidzMesh->vertex(3).getGlobalIndex() == 3);
933 BOOST_TEST(pSolidzMesh->vertex(4).getGlobalIndex() == 4);
934 BOOST_TEST(pSolidzMesh->vertex(5).getGlobalIndex() == 5);
935 BOOST_TEST(pSolidzMesh->vertex(0).isOwner() == true);
936 BOOST_TEST(pSolidzMesh->vertex(1).isOwner() == true);
937 BOOST_TEST(pSolidzMesh->vertex(2).isOwner() == true);
938 BOOST_TEST(pSolidzMesh->vertex(3).isOwner() == true);
939 BOOST_TEST(pSolidzMesh->vertex(4).isOwner() == true);
940 BOOST_TEST(pSolidzMesh->vertex(5).isOwner() == true);
941 }
942}
943
944PRECICE_TEST_SETUP("SOLIDZ"_on(1_rank), "NASTIN"_on(3_ranks).setupIntraComm(), Require::Events)
945BOOST_AUTO_TEST_CASE(TestCompareBoundingBoxes2D)
946{
947 PRECICE_TEST();
948 using namespace precice;
949
951 options.useOnlyPrimaryCom = false;
952 options.useTwoLevelInit = true;
953 auto m2n = context.connectPrimaryRanks("SOLIDZ", "NASTIN", options);
954
955 int dimensions = 2;
956
957 // construct send global boundingbox
958 mesh::Mesh::BoundingBoxMap sendGlobalBB;
959 for (int remoteRank = 0; remoteRank < 3; remoteRank++) {
960 std::vector<double> bounds;
961 for (int i = 0; i < dimensions; i++) {
962 bounds.push_back(3 - remoteRank - 1);
963 bounds.push_back(3 - remoteRank);
964 }
965 sendGlobalBB.emplace(remoteRank, mesh::BoundingBox(bounds));
966 }
967
968 if (context.isNamed("SOLIDZ")) {
969 int connectionMapSize = 0;
970 std::map<int, std::vector<int>> receivedConnectionMap;
971 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
972 m2n->getPrimaryRankCommunication()->send(3, 0);
973 com::sendBoundingBoxMap(*m2n->getPrimaryRankCommunication(), 0, sendGlobalBB);
974 std::vector<int> connectedRanksList = m2n->getPrimaryRankCommunication()->receiveRange(0, com::asVector<int>);
975 connectionMapSize = connectedRanksList.size();
976 BOOST_TEST_REQUIRE(connectionMapSize == 2);
977
978 std::vector<int> connectedRanks;
979 connectedRanks.push_back(-1);
980 for (auto &rank : connectedRanksList) {
981 receivedConnectionMap[rank] = connectedRanks;
982 }
983
984 com::receiveConnectionMap(*m2n->getPrimaryRankCommunication(), 0, receivedConnectionMap);
985
986 // test whether we receive correct connection map
987 BOOST_TEST(receivedConnectionMap.at(0).at(0) == 2);
988 BOOST_TEST(receivedConnectionMap.at(2).at(0) == 0);
989
990 } else {
991 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
992 PtrMesh pNastinMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
993
994 mapping::PtrMapping boundingFromMapping = mapping::PtrMapping(
996 mapping::PtrMapping boundingToMapping = mapping::PtrMapping(
998
999 boundingFromMapping->setMeshes(pSolidzMesh, pNastinMesh);
1000 boundingToMapping->setMeshes(pNastinMesh, pSolidzMesh);
1001
1002 createNastinMesh2D2(pNastinMesh, context.rank);
1003
1004 double safetyFactor = 0.0;
1005
1006 ReceivedPartition part(pSolidzMesh, ReceivedPartition::NO_FILTER, safetyFactor);
1007 part.addM2N(m2n);
1008 part.addFromMapping(boundingFromMapping);
1009 part.addToMapping(boundingToMapping);
1010 part.compareBoundingBoxes();
1011 }
1012}
1013
1014PRECICE_TEST_SETUP("SOLIDZ"_on(1_rank), "NASTIN"_on(3_ranks).setupIntraComm(), Require::Events)
1015BOOST_AUTO_TEST_CASE(TestCompareBoundingBoxes3D)
1016{
1017 PRECICE_TEST();
1018 using namespace precice;
1019
1021 options.useOnlyPrimaryCom = false;
1022 options.useTwoLevelInit = true;
1023 auto m2n = context.connectPrimaryRanks("SOLIDZ", "NASTIN", options);
1024
1025 int dimensions = 3;
1026
1027 // construct send global boundingbox
1028 mesh::Mesh::BoundingBoxMap sendGlobalBB;
1029 for (int remoteRank = 0; remoteRank < 3; remoteRank++) {
1030 std::vector<double> bounds;
1031 for (int i = 0; i < dimensions; i++) {
1032 bounds.push_back(3 - remoteRank - 1);
1033 bounds.push_back(3 - remoteRank);
1034 }
1035 sendGlobalBB.emplace(remoteRank, mesh::BoundingBox(bounds));
1036 }
1037
1038 if (context.isNamed("SOLIDZ")) {
1039 int connectionMapSize = 0;
1040 std::map<int, std::vector<int>> receivedConnectionMap;
1041 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
1042 m2n->getPrimaryRankCommunication()->send(3, 0);
1043 com::sendBoundingBoxMap(*m2n->getPrimaryRankCommunication(), 0, sendGlobalBB);
1044 std::vector<int> connectedRanksList = m2n->getPrimaryRankCommunication()->receiveRange(0, com::asVector<int>);
1045 connectionMapSize = connectedRanksList.size();
1046 BOOST_TEST(connectionMapSize == 2);
1047
1048 std::vector<int> connectedRanks;
1049 connectedRanks.push_back(-1);
1050 for (auto &rank : connectedRanksList) {
1051 receivedConnectionMap[rank] = connectedRanks;
1052 }
1053
1054 com::receiveConnectionMap(*m2n->getPrimaryRankCommunication(), 0, receivedConnectionMap);
1055
1056 // test whether we receive correct connection map
1057 BOOST_TEST(receivedConnectionMap.at(0).at(0) == 2);
1058 BOOST_TEST(receivedConnectionMap.at(2).at(0) == 0);
1059
1060 } else {
1061 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
1062 PtrMesh pNastinMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
1063
1064 mapping::PtrMapping boundingFromMapping = mapping::PtrMapping(
1066 mapping::PtrMapping boundingToMapping = mapping::PtrMapping(
1068
1069 boundingFromMapping->setMeshes(pSolidzMesh, pNastinMesh);
1070 boundingToMapping->setMeshes(pNastinMesh, pSolidzMesh);
1071
1072 createNastinMesh3D2(pNastinMesh, context.rank);
1073
1074 double safetyFactor = 0.0;
1075
1076 ReceivedPartition part(pSolidzMesh, ReceivedPartition::NO_FILTER, safetyFactor);
1077 part.addM2N(m2n);
1078 part.addFromMapping(boundingFromMapping);
1079 part.addToMapping(boundingToMapping);
1080 part.compareBoundingBoxes();
1081 }
1082}
1083
1085{
1086 using namespace precice;
1087 double safetyFactor = 0;
1088
1090 options.useOnlyPrimaryCom = false;
1091 options.useTwoLevelInit = true;
1093
1094 auto participantCom = com::PtrCommunication(new com::SocketCommunication());
1096
1097 auto m2n = std::make_shared<m2n::M2N>(participantCom, distrFactory, options.useOnlyPrimaryCom, options.useTwoLevelInit);
1098
1101 boundingFromMapping->setMeshes(mesh, mesh);
1102 boundingToMapping->setMeshes(mesh, mesh);
1103
1105 part.addM2N(m2n);
1106
1107 part.addFromMapping(boundingFromMapping);
1108 part.addToMapping(boundingToMapping);
1109
1110 mesh->computeBoundingBox();
1111
1113 Access::prepareBoundingBox(part);
1114 Access::tagMeshFirstRound(part);
1115 Access::createOwnerInformation(part);
1116}
1117
1118PRECICE_TEST_SETUP(""_on(4_ranks).setupIntraComm(), Require::Events)
1119BOOST_AUTO_TEST_CASE(parallelSetOwnerInformationVertexCount)
1120{
1121 PRECICE_TEST();
1122 using namespace precice;
1123 /*
1124 This test examines an edge case for parallel setOwnerinformation function in receivedpartition.cpp
1125 for 2LI. The provided mesh includes a vertex at point (0, 0). Initially, all receiving ranks receive
1126 this vertex, but only one of them can own it. Since the rank 2, has the lowest number of vertices,
1127 this vertex must belong only to it finally.
1128 */
1129 // mesh creation
1130 int dimensions = 2;
1131 PtrMesh mesh(new Mesh("mesh", dimensions, testing::nextMeshID()));
1132
1133 if (context.isRank(0)) {
1134 Eigen::VectorXd position(dimensions);
1135 position << 0.0, 0.0;
1136 mesh->createVertex(position);
1137 position << 1.0, 0.0;
1138 mesh->createVertex(position);
1139 position << 2.0, 0.0;
1140 mesh->createVertex(position);
1141 position << 0.0, 1.0;
1142 mesh->createVertex(position);
1143 position << 1.0, 1.0;
1144 mesh->createVertex(position);
1145 position << 2.0, 1.0;
1146 mesh->createVertex(position);
1147
1148 } else if (context.isRank(1)) {
1149 Eigen::VectorXd position(dimensions);
1150 position << 0.0, 0.0;
1151 mesh->createVertex(position);
1152 position << -1.0, 0.0;
1153 mesh->createVertex(position);
1154 position << -2.0, 0.0;
1155 mesh->createVertex(position);
1156 position << -0.5, 1.0;
1157 mesh->createVertex(position);
1158 position << -1.0, 1.0;
1159 mesh->createVertex(position);
1160 position << -2.0, 1.0;
1161 mesh->createVertex(position);
1162 } else if (context.isRank(2)) {
1163 Eigen::VectorXd position(dimensions);
1164 position << 0.0, 0.0;
1165 mesh->createVertex(position);
1166 position << -1.0, -0.5;
1167 mesh->createVertex(position);
1168 } else {
1169 Eigen::VectorXd position(dimensions);
1170 position << 0.0, 0.0;
1171 mesh->createVertex(position);
1172 position << 1.0, -0.5;
1173 mesh->createVertex(position);
1174 position << 2.0, -0.5;
1175 mesh->createVertex(position);
1176 position << 0.5, -1.0;
1177 mesh->createVertex(position);
1178 position << 1.0, -1.0;
1179 mesh->createVertex(position);
1180 position << 2.0, -1.0;
1181 mesh->createVertex(position);
1182 }
1183
1184 mesh->computeBoundingBox();
1185 mesh->setGlobalNumberOfVertices(mesh->nVertices());
1186
1187 for (auto &vertex : mesh->vertices()) {
1189
1190 if (vertex.coord(0) == 0 && vertex.coord(1) == 0) {
1192 }
1193 }
1194
1196
1197 // to check if all ranks have received the vertex at (0, 0)
1198 bool includeVertex = false;
1199
1200 for (auto &vertex : mesh->vertices()) {
1201 if (vertex.getGlobalIndex() == 0) {
1202 includeVertex = true;
1203 if (context.isRank(2)) {
1204 BOOST_TEST(vertex.isOwner() == 1);
1205 } else {
1206 BOOST_TEST(vertex.isOwner() == 0);
1207 }
1208 }
1209 BOOST_TEST(includeVertex == true);
1210 }
1211}
1212
1213PRECICE_TEST_SETUP(""_on(4_ranks).setupIntraComm(), Require::Events)
1214BOOST_AUTO_TEST_CASE(parallelSetOwnerInformationLowerRank)
1215{
1216 PRECICE_TEST();
1217 using namespace precice;
1218 /*
1219 This test examines an edge case for parallel setOwnerinformation function in receivedpartition.cpp
1220 for 2LI. The provided mesh includes a vertices at point (0, 0, 0) and (0, 0, 1). Initially, all
1221 receiving ranks receive this vertex, but only one of them can own it. Since the rank 0, has the lowest
1222 rank number, this vertex must belong only to this rank.
1223 */
1224 // mesh creation
1225 int dimensions = 3;
1226 PtrMesh mesh(new Mesh("mesh", dimensions, testing::nextMeshID()));
1227
1228 if (context.isRank(0)) {
1229 Eigen::VectorXd position(dimensions);
1230 position << 0.0, 0.0, 0.0;
1231 mesh->createVertex(position);
1232 position << 1.0, 0.0, 0.0;
1233 mesh->createVertex(position);
1234 position << 2.0, 0.0, 0.0;
1235 mesh->createVertex(position);
1236 position << 0.0, 1.0, 0.0;
1237 mesh->createVertex(position);
1238 position << 1.0, 1.0, 0.0;
1239 mesh->createVertex(position);
1240 position << 2.0, 1.0, 0.0;
1241 mesh->createVertex(position);
1242 position << 0.0, 0.0, 1.0;
1243 mesh->createVertex(position);
1244 position << 1.0, 0.0, 1.0;
1245 mesh->createVertex(position);
1246 position << 2.0, 0.0, 1.0;
1247 mesh->createVertex(position);
1248 position << 0.0, 1.0, 1.0;
1249 mesh->createVertex(position);
1250 position << 1.0, 1.0, 1.0;
1251 mesh->createVertex(position);
1252 position << 2.0, 1.0, 1.0;
1253 mesh->createVertex(position);
1254
1255 } else if (context.isRank(1)) {
1256 Eigen::VectorXd position(dimensions);
1257 position << 0.0, 0.0, 0.0;
1258 mesh->createVertex(position);
1259 position << -1.0, 0.0, 0.0;
1260 mesh->createVertex(position);
1261 position << -2.0, 0.0, 0.0;
1262 mesh->createVertex(position);
1263 position << -0.1, 1.0, 0.0;
1264 mesh->createVertex(position);
1265 position << -1.0, 1.0, 0.0;
1266 mesh->createVertex(position);
1267 position << -2.0, 1.0, 0.0;
1268 mesh->createVertex(position);
1269 position << 0.0, 0.0, 1.0;
1270 mesh->createVertex(position);
1271 position << -1.0, 0.0, 1.0;
1272 mesh->createVertex(position);
1273 position << -2.0, 0.0, 1.0;
1274 mesh->createVertex(position);
1275 position << -0.1, 1.0, 1.0;
1276 mesh->createVertex(position);
1277 position << -1.0, 1.0, 1.0;
1278 mesh->createVertex(position);
1279 position << -2.0, 1.0, 1.0;
1280 mesh->createVertex(position);
1281 } else if (context.isRank(2)) {
1282 Eigen::VectorXd position(dimensions);
1283 position << 0.0, 0.0, 0.0;
1284 mesh->createVertex(position);
1285 position << -1.0, -0.1, 0.0;
1286 mesh->createVertex(position);
1287 position << -2.0, -0.1, 0.0;
1288 mesh->createVertex(position);
1289 position << 0.0, -1.0, 0.0;
1290 mesh->createVertex(position);
1291 position << -1.0, -1.0, 0.0;
1292 mesh->createVertex(position);
1293 position << -2.0, -1.0, 0.0;
1294 mesh->createVertex(position);
1295 position << 0.0, 0.0, 1.0;
1296 mesh->createVertex(position);
1297 position << -1.0, -0.1, 1.0;
1298 mesh->createVertex(position);
1299 position << -2.0, -0.1, 1.0;
1300 mesh->createVertex(position);
1301 position << 0.0, -1.0, 1.0;
1302 mesh->createVertex(position);
1303 position << -1.0, -1.0, 1.0;
1304 mesh->createVertex(position);
1305 position << -2.0, -1.0, 1.0;
1306 mesh->createVertex(position);
1307 } else {
1308 Eigen::VectorXd position(dimensions);
1309 position << 0.0, 0.0, 0.0;
1310 mesh->createVertex(position);
1311 position << 1.0, -0.1, 0.0;
1312 mesh->createVertex(position);
1313 position << 2.0, -0.1, 0.0;
1314 mesh->createVertex(position);
1315 position << 0.0, -1.0, 0.0;
1316 mesh->createVertex(position);
1317 position << 1.0, -1.0, 0.0;
1318 mesh->createVertex(position);
1319 position << 2.0, -1.0, 0.0;
1320 mesh->createVertex(position);
1321 position << 0.0, 0.0, 1.0;
1322 mesh->createVertex(position);
1323 position << 1.0, -0.1, 1.0;
1324 mesh->createVertex(position);
1325 position << 2.0, -0.1, 1.0;
1326 mesh->createVertex(position);
1327 position << 0.0, -1.0, 1.0;
1328 mesh->createVertex(position);
1329 position << 1.0, -1.0, 1.0;
1330 mesh->createVertex(position);
1331 position << 2.0, -1.0, 1.0;
1332 mesh->createVertex(position);
1333 }
1334
1335 mesh->computeBoundingBox();
1336 mesh->setGlobalNumberOfVertices(mesh->nVertices());
1337
1338 for (auto &vertex : mesh->vertices()) {
1340
1341 if (vertex.coord(0) == 0 && vertex.coord(1) == 0) {
1342 if (vertex.coord(2) == 0) {
1344 } else if (vertex.coord(2) == 1) {
1346 }
1347 }
1348 }
1349
1351
1352 // to check if all ranks have received the vertex at (0, 0, 0)
1353 bool includeVertex = false;
1354
1355 for (auto &vertex : mesh->vertices()) {
1356 if (vertex.getGlobalIndex() == 0) {
1357 includeVertex = true;
1358 if (context.isRank(0)) {
1359 BOOST_TEST(vertex.isOwner() == 1);
1360 } else {
1361 BOOST_TEST(vertex.isOwner() == 0);
1362 }
1363 }
1364 BOOST_TEST(includeVertex == true);
1365 }
1366}
1367
1368PRECICE_TEST_SETUP(""_on(4_ranks).setupIntraComm(), Require::Events)
1369BOOST_AUTO_TEST_CASE(parallelSetOwnerInformationEmptyPartition)
1370{
1371 PRECICE_TEST();
1372 using namespace precice;
1373 /*
1374 This test examines an edge case for parallel setOwnerinformation function in receivedpartition.cpp
1375 for 2LI. The provided mesh includes vertices at points (0, 0, 0) and (0, 0, 1). Rank 2 has an
1376 empty mesh partition. Initially, all ranks (except rank 2) receive this vertex, but only one of them
1377 can own it. Since the rank 0, has the lowest rank number, this vertex must belong only to this rank.
1378 */
1379 // mesh creation
1380 int dimensions = 3;
1381 PtrMesh mesh(new Mesh("mesh", dimensions, testing::nextMeshID()));
1382
1383 if (context.isRank(0)) {
1384 Eigen::VectorXd position(dimensions);
1385 position << 0.0, 0.0, 0.0;
1386 mesh->createVertex(position);
1387 position << 1.0, 0.0, 0.0;
1388 mesh->createVertex(position);
1389 position << 2.0, 0.0, 0.0;
1390 mesh->createVertex(position);
1391 position << 0.0, 1.0, 0.0;
1392 mesh->createVertex(position);
1393 position << 1.0, 1.0, 0.0;
1394 mesh->createVertex(position);
1395 position << 2.0, 1.0, 0.0;
1396 mesh->createVertex(position);
1397 position << 0.0, 0.0, 1.0;
1398 mesh->createVertex(position);
1399 position << 1.0, 0.0, 1.0;
1400 mesh->createVertex(position);
1401 position << 2.0, 0.0, 1.0;
1402 mesh->createVertex(position);
1403 position << 0.0, 1.0, 1.0;
1404 mesh->createVertex(position);
1405 position << 1.0, 1.0, 1.0;
1406 mesh->createVertex(position);
1407 position << 2.0, 1.0, 1.0;
1408 mesh->createVertex(position);
1409
1410 } else if (context.isRank(1)) {
1411 Eigen::VectorXd position(dimensions);
1412 position << 0.0, 0.0, 0.0;
1413 mesh->createVertex(position);
1414 position << -1.0, 0.0, 0.0;
1415 mesh->createVertex(position);
1416 position << -2.0, 0.0, 0.0;
1417 mesh->createVertex(position);
1418 position << -0.1, 1.0, 0.0;
1419 mesh->createVertex(position);
1420 position << -1.0, 1.0, 0.0;
1421 mesh->createVertex(position);
1422 position << -2.0, 1.0, 0.0;
1423 mesh->createVertex(position);
1424 position << 0.0, 0.0, 1.0;
1425 mesh->createVertex(position);
1426 position << -1.0, 0.0, 1.0;
1427 mesh->createVertex(position);
1428 position << -2.0, 0.0, 1.0;
1429 mesh->createVertex(position);
1430 position << -0.1, 1.0, 1.0;
1431 mesh->createVertex(position);
1432 position << -1.0, 1.0, 1.0;
1433 mesh->createVertex(position);
1434 position << -2.0, 1.0, 1.0;
1435 mesh->createVertex(position);
1436 } else if (context.isRank(2)) {
1437 } else {
1438 Eigen::VectorXd position(dimensions);
1439 position << 0.0, 0.0, 0.0;
1440 mesh->createVertex(position);
1441 position << 1.0, -0.1, 0.0;
1442 mesh->createVertex(position);
1443 position << 2.0, -0.1, 0.0;
1444 mesh->createVertex(position);
1445 position << 0.0, -1.0, 0.0;
1446 mesh->createVertex(position);
1447 position << 1.0, -1.0, 0.0;
1448 mesh->createVertex(position);
1449 position << 2.0, -1.0, 0.0;
1450 mesh->createVertex(position);
1451 position << 0.0, 0.0, 1.0;
1452 mesh->createVertex(position);
1453 position << 1.0, -0.1, 1.0;
1454 mesh->createVertex(position);
1455 position << 2.0, -0.1, 1.0;
1456 mesh->createVertex(position);
1457 position << 0.0, -1.0, 1.0;
1458 mesh->createVertex(position);
1459 position << 1.0, -1.0, 1.0;
1460 mesh->createVertex(position);
1461 position << 2.0, -1.0, 1.0;
1462 mesh->createVertex(position);
1463 }
1464
1465 mesh->computeBoundingBox();
1466 mesh->setGlobalNumberOfVertices(mesh->nVertices());
1467
1468 for (auto &vertex : mesh->vertices()) {
1470
1471 if (vertex.coord(0) == 0 && vertex.coord(1) == 0) {
1472 if (vertex.coord(2) == 0) {
1474 } else if (vertex.coord(2) == 1) {
1476 }
1477 }
1478 }
1479
1481
1482 // to check if all ranks have received the vertex at (0, 0, 0)
1483 bool includeVertex = false;
1484
1485 for (auto &vertex : mesh->vertices()) {
1486 if (vertex.getGlobalIndex() == 0) {
1487 includeVertex = true;
1488 if (context.isRank(0)) {
1489 BOOST_TEST(vertex.isOwner() == 1);
1490 } else {
1491 BOOST_TEST(vertex.isOwner() == 0);
1492 }
1493 }
1494 BOOST_TEST(includeVertex == true);
1495 }
1496}
1497
1498// Test with two "from" and two "to" mappings
1499PRECICE_TEST_SETUP("Solid"_on(1_rank), "Fluid"_on(3_ranks).setupIntraComm(), Require::Events)
1500BOOST_AUTO_TEST_CASE(RePartitionMultipleMappings)
1501{
1502 PRECICE_TEST();
1503 using namespace precice;
1504 auto m2n = context.connectPrimaryRanks("Solid", "Fluid");
1505
1506 int dimensions = 2;
1507 Eigen::VectorXd offset = Eigen::VectorXd::Zero(dimensions);
1508
1509 if (context.isNamed("Solid")) { // SOLIDZ
1510 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
1511 createSolidzMesh2D(pSolidzMesh);
1512 BOOST_TEST(pSolidzMesh->nVertices() == 6);
1513 ProvidedPartition part(pSolidzMesh);
1514 part.addM2N(m2n);
1515 part.communicate();
1516 } else {
1517 BOOST_TEST(context.isNamed("Fluid"));
1518 PtrMesh pNastinMesh1(new Mesh("NastinMesh1", dimensions, testing::nextMeshID()));
1519 PtrMesh pNastinMesh2(new Mesh("NastinMesh1", dimensions, testing::nextMeshID()));
1520 PtrMesh pNastinMesh3(new Mesh("NastinMesh1", dimensions, testing::nextMeshID()));
1521 PtrMesh pSolidzMesh(new Mesh("SolidzMesh", dimensions, testing::nextMeshID()));
1522
1523 mapping::PtrMapping boundingFromMapping1 = mapping::PtrMapping(
1525 mapping::PtrMapping boundingToMapping1 = mapping::PtrMapping(
1527 mapping::PtrMapping boundingFromMapping2 = mapping::PtrMapping(
1529 mapping::PtrMapping boundingToMapping2 = mapping::PtrMapping(
1531 boundingFromMapping1->setMeshes(pSolidzMesh, pNastinMesh1);
1532 boundingToMapping1->setMeshes(pNastinMesh1, pSolidzMesh);
1533 boundingFromMapping2->setMeshes(pSolidzMesh, pNastinMesh2);
1534 boundingToMapping2->setMeshes(pNastinMesh3, pSolidzMesh);
1535
1536 if (context.rank == 0) {
1537 Eigen::VectorXd position(dimensions);
1538 position << 0.0, 0.0;
1539 pNastinMesh1->createVertex(position);
1540 position << 0.0, 2.0;
1541 pNastinMesh2->createVertex(position);
1542 } else if (context.rank == 1) {
1543 // not at interface
1544 } else if (context.rank == 2) {
1545 Eigen::VectorXd position(dimensions);
1546 position << 0.0, 4.0;
1547 pNastinMesh2->createVertex(position);
1548 position << 0.0, 6.0;
1549 pNastinMesh3->createVertex(position);
1550 }
1551 pNastinMesh1->computeBoundingBox();
1552 pNastinMesh2->computeBoundingBox();
1553 pNastinMesh3->computeBoundingBox();
1554
1555 double safetyFactor = 0.1;
1556
1557 ReceivedPartition part(pSolidzMesh, ReceivedPartition::ON_SECONDARY_RANKS, safetyFactor);
1558 part.addM2N(m2n);
1559 part.addFromMapping(boundingFromMapping1);
1560 part.addToMapping(boundingToMapping1);
1561 part.addFromMapping(boundingFromMapping2);
1562 part.addToMapping(boundingToMapping2);
1563 part.communicate();
1564 part.compute();
1565
1566 BOOST_TEST_CONTEXT(*pSolidzMesh)
1567 {
1568 // check if the sending and filtering worked right
1569 if (context.isPrimary()) { // Primary
1570 BOOST_TEST(pSolidzMesh->nVertices() == 2);
1571 BOOST_TEST(pSolidzMesh->edges().size() == 1);
1572 } else if (context.isRank(1)) { // SecondaryRank1
1573 BOOST_TEST(pSolidzMesh->nVertices() == 0);
1574 BOOST_TEST(pSolidzMesh->edges().size() == 0);
1575 } else if (context.isRank(2)) { // Secondary rank 2
1576 BOOST_TEST(pSolidzMesh->nVertices() == 2);
1577 BOOST_TEST(pSolidzMesh->edges().size() == 1);
1578 }
1579 }
1580 }
1581}
1582
1585
1586#endif // PRECICE_NO_MPI
BOOST_AUTO_TEST_CASE(testIQNIMVJPPWithSubsteps)
BOOST_AUTO_TEST_SUITE(PreProcess)
BOOST_AUTO_TEST_SUITE_END()
void createNastinMesh2D(PtrMesh pNastinMesh, Rank rank)
void createNastinMesh2D2(PtrMesh pNastinMesh, Rank rank)
void createSolidzMesh3D(PtrMesh pSolidzMesh)
void createSolidzMesh2DSmall(PtrMesh pSolidzMesh)
void createNastinMesh3D(PtrMesh pNastinMesh, Rank rank)
void createSolidzMesh2D(PtrMesh pSolidzMesh)
void testParallelSetOwnerInformation(PtrMesh mesh, int dimensions)
void createNastinMesh3D2(PtrMesh pNastinMesh, Rank rank)
#define PRECICE_TEST()
Definition Testing.hpp:39
#define PRECICE_TEST_SETUP(...)
Creates and attaches a TestSetup to a Boost test case.
Definition Testing.hpp:29
#define PRECICE_ASSERT(...)
Definition assertion.hpp:85
T at(T... args)
@ ON_PRIMARY_RANK
Filter at primary rank and communicate only filtered mesh.
@ ON_SECONDARY_RANKS
Filter after communication on all secondary ranks.
@ NO_FILTER
No geometric filter used (e.g. for RBF mappings)
Implements Communication by using sockets.
std::shared_ptr< DistributedComFactory > SharedPointer
Radial basis function with compact support.
Mapping using nearest neighboring vertices.
Mapping using orthogonal projection to nearest triangle/edge/vertex and linear interpolation from pro...
Mapping with radial basis functions using the Petsc library to solve the resulting system.
Radial basis function with global support.
An axis-aligned bounding box around a (partition of a) mesh.
Linear edge of a mesh, defined by two Vertex objects.
Definition Edge.hpp:15
Vertex & vertex(int i)
Returns the edge's vertex with index 0 or 1.
Definition Edge.hpp:76
Container and creator for meshes.
Definition Mesh.hpp:38
Triangle & createTriangle(Edge &edgeOne, Edge &edgeTwo, Edge &edgeThree)
Creates and initializes a Triangle object.
Definition Mesh.cpp:121
int getGlobalNumberOfVertices() const
Definition Mesh.hpp:265
int getDimensions() const
Definition Mesh.cpp:100
std::size_t nVertices() const
Returns the number of vertices.
Definition Mesh.cpp:65
Vertex & vertex(VertexID id)
Mutable access to a vertex by VertexID.
Definition Mesh.cpp:43
std::map< int, BoundingBox > BoundingBoxMap
Definition Mesh.hpp:45
const VertexOffsets & getVertexOffsets() const
Definition Mesh.hpp:251
void computeBoundingBox()
Computes the boundingBox for the vertices.
Definition Mesh.cpp:244
TriangleContainer & triangles()
Returns modifiable container holding all triangles.
Definition Mesh.cpp:80
Edge & createEdge(Vertex &vertexOne, Vertex &vertexTwo)
Creates and initializes an Edge object.
Definition Mesh.cpp:113
Vertex & createVertex(const Eigen::Ref< const Eigen::VectorXd > &coords)
Creates and initializes a Vertex object.
Definition Mesh.cpp:105
EdgeContainer & edges()
Returns modifiable container holding all edges.
Definition Mesh.cpp:70
Vertex of a mesh.
Definition Vertex.hpp:16
double coord(int index) const
Returns a coordinate of a vertex.
Definition Vertex.hpp:126
VertexID getID() const
Returns the unique (among vertices of one mesh on one processor) ID of the vertex.
Definition Vertex.hpp:109
void setGlobalIndex(int globalIndex)
Definition Vertex.cpp:17
bool isOwner() const
Definition Vertex.cpp:22
int getGlobalIndex() const
Globally unique index.
Definition Vertex.cpp:12
void addFromMapping(mapping::PtrMapping fromMapping)
Definition Partition.hpp:46
void addM2N(m2n::PtrM2N m2n)
Definition Partition.hpp:56
void addToMapping(mapping::PtrMapping toMapping)
Definition Partition.hpp:51
A partition that is provided by the participant.
void compute() override
All distribution data structures are set up.
void communicate() override
The mesh is gathered and sent to another participant (if required)
A partition that is computed from a mesh received from another participant.
void compute() override
The partition is computed, i.e. the mesh re-partitioned if required and all data structures are set u...
void compareBoundingBoxes() override
Intersections between bounding boxes around each rank are computed.
void communicate() override
The mesh is communicated between both primary ranks (if required)
static Rank getRank()
Current rank.
Definition IntraComm.cpp:42
T emplace(T... args)
T make_shared(T... args)
constexpr auto asVector
Allows to use Communication::AsVectorTag in a less verbose way.
void receiveConnectionMap(Communication &communication, int rankSender, mesh::Mesh::ConnectionMap &cm)
Definition Extra.cpp:33
void sendBoundingBoxMap(Communication &communication, int rankReceiver, const mesh::Mesh::BoundingBoxMap &bbm)
Definition Extra.cpp:58
std::shared_ptr< Communication > PtrCommunication
contains the logic of the parallel communication between participants.
Definition BoundM2N.cpp:12
std::shared_ptr< Mapping > PtrMapping
provides Mesh, Data and primitives.
std::shared_ptr< Mesh > PtrMesh
@ PETSc
Require to initialize PETSc. This implies the initialization of Events.
@ Events
Require to initialize Event.
Main namespace of the precice library.
int Rank
Definition Types.hpp:37
T push_back(T... args)
T size(T... args)
T use_count(T... args)