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