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