46 auto m2n = context.connectPrimaryRanks(
"NASTIN",
"SOLIDZ");
50 if (context.isNamed(
"NASTIN")) {
53 double safetyFactor = 0.1;
59 BOOST_TEST(pSolidzMesh->
nVertices() == 6);
60 BOOST_TEST(pSolidzMesh->
edges().
size() == 4);
62 for (
int i = 0; i < 6; i++) {
68 if (context.isPrimary()) {
69 Eigen::VectorXd position(dimensions);
75 }
else if (context.isRank(1)) {
76 }
else if (context.isRank(2)) {
77 Eigen::VectorXd position(dimensions);
98 if (context.isPrimary()) {
102 }
else if (context.isRank(1)) {
119 auto m2n = context.connectPrimaryRanks(
"NASTIN",
"SOLIDZ");
123 if (context.isNamed(
"NASTIN")) {
126 double safetyFactor = 0.1;
132 BOOST_TEST(pSolidzMesh->nVertices() == 6);
133 BOOST_TEST(pSolidzMesh->edges().size() == 6);
134 BOOST_TEST(pSolidzMesh->triangles().size() == 2);
136 for (
int i = 0; i < 6; i++) {
137 BOOST_TEST(pSolidzMesh->vertex(i).getGlobalIndex() == i);
142 if (context.isPrimary()) {
143 Eigen::VectorXd position(dimensions);
144 position << 0.0, 0.0, 0.0;
146 position << 0.0, 1.5, 1.0;
148 pSolidzMesh->createEdge(v1, v2);
149 }
else if (context.isRank(1)) {
150 }
else if (context.isRank(2)) {
151 Eigen::VectorXd position(dimensions);
152 position << 0.0, 3.5, 0.1;
154 position << 0.0, 4.5, 0.2;
156 position << 0.0, 5.5, 0.8;
158 position << 0.0, 7.0, 0.4;
160 mesh::Edge &e1 = pSolidzMesh->createEdge(v3, v4);
161 mesh::Edge &e2 = pSolidzMesh->createEdge(v4, v5);
162 mesh::Edge &e3 = pSolidzMesh->createEdge(v5, v3);
163 mesh::Edge &e4 = pSolidzMesh->createEdge(v3, v6);
164 mesh::Edge &e5 = pSolidzMesh->createEdge(v6, v5);
166 pSolidzMesh->createTriangle(e1, e2, e3);
167 pSolidzMesh->createTriangle(e4, e5, e3);
169 pSolidzMesh->computeBoundingBox();
176 BOOST_TEST(pSolidzMesh->getGlobalNumberOfVertices() == 6);
177 const auto &vertices = pSolidzMesh->vertices();
178 const auto &vertexOffsets = pSolidzMesh->getVertexOffsets();
179 const auto &vertexDistribution = pSolidzMesh->getVertexDistribution();
181 if (context.isPrimary()) {
182 BOOST_REQUIRE(vertexOffsets.size() == 3);
183 BOOST_TEST(vertexOffsets.at(0) == 2);
184 BOOST_TEST(vertexOffsets.at(1) == 2);
185 BOOST_TEST(vertexOffsets.at(2) == 6);
187 BOOST_REQUIRE(vertices.size() == 2);
188 BOOST_TEST(vertices.at(0).getGlobalIndex() == 0);
189 BOOST_TEST(vertices.at(1).getGlobalIndex() == 1);
190 BOOST_TEST(vertices.at(0).isOwner() ==
true);
191 BOOST_TEST(vertices.at(1).isOwner() ==
true);
193 BOOST_REQUIRE((vertexDistribution.size()) == 3);
194 BOOST_TEST(vertexDistribution.at(0).size() == 2);
195 BOOST_TEST(vertexDistribution.at(1).size() == 0);
196 BOOST_TEST(vertexDistribution.at(2).size() == 4);
197 BOOST_TEST(vertexDistribution.at(0).at(0) == 0);
198 BOOST_TEST(vertexDistribution.at(0).at(1) == 1);
199 BOOST_TEST(vertexDistribution.at(2).at(0) == 2);
200 BOOST_TEST(vertexDistribution.at(2).at(1) == 3);
201 BOOST_TEST(vertexDistribution.at(2).at(2) == 4);
202 BOOST_TEST(vertexDistribution.at(2).at(3) == 5);
203 }
else if (context.isRank(1)) {
204 BOOST_REQUIRE(vertexOffsets.size() == 3);
205 BOOST_TEST(vertexOffsets.at(0) == 2);
206 BOOST_TEST(vertexOffsets.at(1) == 2);
207 BOOST_TEST(vertexOffsets.at(2) == 6);
208 }
else if (context.isRank(2)) {
209 BOOST_REQUIRE(vertexOffsets.size() == 3);
210 BOOST_TEST(vertexOffsets.at(0) == 2);
211 BOOST_TEST(vertexOffsets.at(1) == 2);
212 BOOST_TEST(vertexOffsets.at(2) == 6);
214 BOOST_REQUIRE(vertices.size() == 4);
215 BOOST_TEST(vertices.at(0).getGlobalIndex() == 2);
216 BOOST_TEST(vertices.at(1).getGlobalIndex() == 3);
217 BOOST_TEST(vertices.at(2).getGlobalIndex() == 4);
218 BOOST_TEST(vertices.at(3).getGlobalIndex() == 5);
219 BOOST_TEST(vertices.at(0).isOwner() ==
true);
220 BOOST_TEST(vertices.at(1).isOwner() ==
true);
221 BOOST_TEST(vertices.at(2).isOwner() ==
true);
222 BOOST_TEST(vertices.at(3).isOwner() ==
true);
237 if (context.isPrimary()) {
238 Eigen::VectorXd position(dim);
239 position << 0.0, 0.0;
241 position << 1.0, 0.0;
243 }
else if (context.isRank(1)) {
244 Eigen::VectorXd position(dim);
245 position << 2.0, 0.0;
247 }
else if (context.isRank(2)) {
248 }
else if (context.isRank(3)) {
249 Eigen::VectorXd position(dim);
250 position << 3.0, 0.0;
252 position << 4.0, 0.0;
261 BOOST_TEST_CONTEXT(*pMesh)
263 if (context.isPrimary()) {
274 }
else if (context.isRank(1)) {
283 }
else if (context.isRank(2)) {
290 }
else if (context.isRank(3)) {
313 auto m2n = context.connectPrimaryRanks(
"NASTIN",
"SOLIDZ", options);
317 if (context.isNamed(
"SOLIDZ")) {
321 if (context.isPrimary()) {
322 Eigen::VectorXd position(dimensions);
323 position << -1.0, 0.0;
325 position << 1.0, 2.0;
327 position << 5.0, 3.0;
333 else if (context.isRank(1)) {
334 Eigen::VectorXd position(dimensions);
335 position << 1.0, 3.5;
337 position << 0.0, 4.5;
340 }
else if (context.isRank(2)) {
341 Eigen::VectorXd position(dimensions);
342 position << 2.5, 5.5;
344 position << 4.5, 7.0;
354 if (context.isPrimary()) {
358 }
else if (context.isRank(1)) {
362 }
else if (context.isRank(2)) {
369 BOOST_TEST(context.isNamed(
"NASTIN"));
380 int receivedFeedbackSize = 3;
381 m2n->getPrimaryRankCommunication()->receive(receivedFeedbackSize, 0);
383 for (
int i = 0; i < receivedFeedbackSize; i++) {
384 receivedGlobalBB.
emplace(i, localBB);
390 BOOST_TEST(receivedFeedbackSize == 3);
393 BOOST_TEST(receivedGlobalBB.
at(0) == compareBB.
at(0));
394 BOOST_TEST(receivedGlobalBB.
at(1) == compareBB.
at(1));
395 BOOST_TEST(receivedGlobalBB.
at(2) == compareBB.
at(2));
398 m2n->getPrimaryRankCommunication()->sendRange(connectedRanks, 0);
402 connectionMap[0].push_back(1);
403 connectionMap[0].push_back(2);
404 connectionMap[1].push_back(0);
405 connectionMap[1].push_back(2);
406 connectionMap[2].push_back(0);
407 connectionMap[2].push_back(1);
421 auto m2n = context.connectPrimaryRanks(
"NASTIN",
"SOLIDZ", options);
425 if (context.isNamed(
"SOLIDZ")) {
429 if (context.isPrimary()) {
430 Eigen::VectorXd position(dimensions);
431 position << -1.0, 0.0, -1.0;
433 position << 1.0, 2.0, 1.0;
435 position << 5.0, 3.0, 5.0;
437 pSolidzMesh->createEdge(v0, v1);
438 pSolidzMesh->createEdge(v1, v2);
441 else if (context.isRank(1)) {
442 Eigen::VectorXd position(dimensions);
443 position << 1.0, 3.5, 1.0;
445 position << 0.0, 4.5, 0.0;
447 pSolidzMesh->createEdge(v3, v4);
448 }
else if (context.isRank(2)) {
449 Eigen::VectorXd position(dimensions);
450 position << 2.5, 5.5, 2.5;
452 position << 4.5, 7.0, 4.5;
454 pSolidzMesh->createEdge(v5, v6);
456 pSolidzMesh->computeBoundingBox();
460 part.compareBoundingBoxes();
463 BOOST_TEST(context.isNamed(
"NASTIN"));
474 int remoteParComSize = 3;
475 m2n->getPrimaryRankCommunication()->receive(remoteParComSize, 0);
477 for (
int i = 0; i < remoteParComSize; i++) {
478 receivedGlobalBB.
emplace(i, localBB);
485 BOOST_TEST(remoteParComSize == 3);
488 BOOST_TEST(receivedGlobalBB.
at(0) == compareBB.
at(0));
489 BOOST_TEST(receivedGlobalBB.
at(1) == compareBB.
at(1));
490 BOOST_TEST(receivedGlobalBB.
at(2) == compareBB.
at(2));
494 m2n->getPrimaryRankCommunication()->sendRange(connectedRanksList, 0);
505 double safetyFactor = 0.1;
512 auto m2n = context.connectPrimaryRanks(
"Fluid",
"Solid", options);
514 if (context.isNamed(
"Solid")) {
515 if (context.isPrimary()) {
516 Eigen::VectorXd position(dimensions);
517 position << 0.5, 0.0;
519 position << 1.5, 0.0;
521 position << 2.0, 1.0;
523 position << 0.5, 1.0;
525 mesh->createEdge(v1, v2);
526 mesh->createEdge(v2, v3);
527 mesh->createEdge(v3, v4);
528 mesh->createEdge(v4, v1);
530 mesh->setConnectedRanks({0});
533 Eigen::VectorXd position(dimensions);
534 position << 2.5, 0.0;
536 position << 3.5, 0.0;
538 position << 3.5, 1.0;
540 position << 2.0, 1.0;
542 mesh->createEdge(v1, v2);
543 mesh->createEdge(v2, v3);
544 mesh->createEdge(v3, v4);
545 mesh->createEdge(v4, v1);
547 mesh->setConnectedRanks({1});
550 BOOST_TEST(context.isNamed(
"Fluid"));
551 if (context.isPrimary()) {
552 mesh->setConnectedRanks({0});
554 mesh->setConnectedRanks({1});
557 mesh->computeBoundingBox();
559 if (context.isNamed(
"Solid")) {
560 m2n->createDistributedCommunication(
mesh);
562 m2n->acceptSecondaryRanksPreConnection(
"SolidSecondaryRanks",
"FluidSecondaryRanks");
566 m2n->createDistributedCommunication(
mesh);
568 m2n->requestSecondaryRanksPreConnection(
"SolidSecondaryRanks",
"FluidSecondaryRanks");
573 BOOST_TEST(
mesh->nVertices() == 4);
575 if (context.isPrimary()) {
576 BOOST_TEST(
mesh->vertex(0).coord(0) == 0.5);
577 BOOST_TEST(
mesh->vertex(0).coord(1) == 0.0);
578 BOOST_TEST(
mesh->vertex(1).coord(0) == 1.5);
579 BOOST_TEST(
mesh->vertex(1).coord(1) == 0.0);
580 BOOST_TEST(
mesh->vertex(2).coord(0) == 2.0);
581 BOOST_TEST(
mesh->vertex(2).coord(1) == 1.0);
582 BOOST_TEST(
mesh->vertex(3).coord(0) == 0.5);
583 BOOST_TEST(
mesh->vertex(3).coord(1) == 1.0);
585 BOOST_TEST(
mesh->vertex(0).coord(0) == 2.5);
586 BOOST_TEST(
mesh->vertex(0).coord(1) == 0.0);
587 BOOST_TEST(
mesh->vertex(1).coord(0) == 3.5);
588 BOOST_TEST(
mesh->vertex(1).coord(1) == 0.0);
589 BOOST_TEST(
mesh->vertex(2).coord(0) == 3.5);
590 BOOST_TEST(
mesh->vertex(2).coord(1) == 1.0);
591 BOOST_TEST(
mesh->vertex(3).coord(0) == 2.0);
592 BOOST_TEST(
mesh->vertex(3).coord(1) == 1.0);
604 double safetyFactor = 0;
612 auto m2n = context.connectPrimaryRanks(
"Fluid",
"Solid", options);
614 if (context.isNamed(
"Solid")) {
615 if (context.isPrimary()) {
616 Eigen::VectorXd position(dimensions);
617 position << -2.0, 0.0;
618 mesh->createVertex(position);
619 position << -1.0, 0.0;
620 mesh->createVertex(position);
621 position << 0.0, 1.0;
622 mesh->createVertex(position);
623 position << -1.0, 1.0;
624 mesh->createVertex(position);
625 position << -2.0, 1.0;
626 mesh->createVertex(position);
627 position << -2.0, 2.0;
628 mesh->createVertex(position);
629 position << -1.0, 2.0;
630 mesh->createVertex(position);
631 position << 0.0, 2.0;
632 mesh->createVertex(position);
634 Eigen::VectorXd position(dimensions);
635 position << -0.5, 0.0;
636 mesh->createVertex(position);
637 position << 1.0, 0.0;
638 mesh->createVertex(position);
639 position << 2.0, 0.0;
640 mesh->createVertex(position);
641 position << 2.0, 1.0;
642 mesh->createVertex(position);
643 position << 1.0, 1.0;
644 mesh->createVertex(position);
645 position << 1.0, 2.0;
646 mesh->createVertex(position);
647 position << 2.0, 2.0;
648 mesh->createVertex(position);
651 BOOST_TEST(context.isNamed(
"Fluid"));
652 if (context.isPrimary()) {
653 Eigen::VectorXd position(dimensions);
654 position << 0.0, 0.0;
655 mesh->createVertex(position);
656 position << 0.0, -1.0;
657 mesh->createVertex(position);
658 position << -1.0, 0.0;
659 mesh->createVertex(position);
660 position << -1.0, -1.0;
661 mesh->createVertex(position);
662 position << -2.0, -0.0;
663 mesh->createVertex(position);
664 position << -2.0, -1.0;
665 mesh->createVertex(position);
667 Eigen::VectorXd position(dimensions);
668 position << 0.0, 0.0;
669 mesh->createVertex(position);
670 position << 1.0, 0.0;
671 mesh->createVertex(position);
672 position << 0.0, -1.0;
673 mesh->createVertex(position);
674 position << 1.0, -1.0;
675 mesh->createVertex(position);
676 position << 2.0, 0.0;
677 mesh->createVertex(position);
678 position << 2.0, -1.0;
679 mesh->createVertex(position);
682 mesh->computeBoundingBox();
684 if (context.isNamed(
"Solid")) {
685 m2n->createDistributedCommunication(
mesh);
689 part.compareBoundingBoxes();
691 if (context.isPrimary()) {
692 BOOST_TEST(
mesh->getConnectedRanks().size() == 2);
693 BOOST_TEST(
mesh->getConnectedRanks().at(0) == 0);
694 BOOST_TEST(
mesh->getConnectedRanks().at(1) == 1);
696 BOOST_TEST(
mesh->getConnectedRanks().size() == 2);
697 BOOST_TEST(
mesh->getConnectedRanks().at(0) == 0);
698 BOOST_TEST(
mesh->getConnectedRanks().at(1) == 1);
701 m2n->acceptSecondaryRanksPreConnection(
"FluidSecondaryRanks",
"SolidSecondaryRanks");
706 if (context.isPrimary()) {
707 BOOST_TEST(
mesh->getCommunicationMap().at(0).at(0) == 0);
708 BOOST_TEST(
mesh->getCommunicationMap().at(0).at(1) == 1);
710 BOOST_TEST(
mesh->getCommunicationMap().at(0).at(0) == 0);
711 BOOST_TEST(
mesh->getCommunicationMap().at(1).at(0) == 1);
712 BOOST_TEST(
mesh->getCommunicationMap().at(1).at(1) == 2);
715 m2n->createDistributedCommunication(receivedMesh);
718 boundingFromMapping->setMeshes(receivedMesh,
mesh);
719 boundingToMapping->setMeshes(
mesh, receivedMesh);
725 part.addFromMapping(boundingFromMapping);
726 part.addToMapping(boundingToMapping);
728 part.compareBoundingBoxes();
730 m2n->requestSecondaryRanksPreConnection(
"FluidSecondaryRanks",
"SolidSecondaryRanks");
745 double safetyFactor = 0.0;
754 auto m2n = context.connectPrimaryRanks(
"Fluid",
"Solid", options);
756 if (context.isNamed(
"Solid")) {
757 if (context.isPrimary()) {
758 Eigen::VectorXd position(dimensions);
759 position << -2.0, 0.0, 0.0;
760 mesh->createVertex(position);
761 position << -1.0, 0.0, 0.0;
762 mesh->createVertex(position);
763 position << 0.0, 1.0, 1.0;
764 mesh->createVertex(position);
765 position << -1.0, 1.0, 1.0;
766 mesh->createVertex(position);
767 position << -2.0, 1.0, 1.0;
768 mesh->createVertex(position);
770 Eigen::VectorXd position(dimensions);
771 position << -0.5, 0.0, 0.0;
772 mesh->createVertex(position);
773 position << 1.0, 0.0, 0.0;
774 mesh->createVertex(position);
775 position << 2.0, 0.0, 0.0;
776 mesh->createVertex(position);
777 position << 2.0, 1.0, 1.0;
778 mesh->createVertex(position);
779 position << 1.0, 1.0, 1.0;
780 mesh->createVertex(position);
783 if (context.isPrimary()) {
784 Eigen::VectorXd position(dimensions);
785 position << 0.0, 0.0, 0.0;
786 mesh->createVertex(position);
787 position << 0.0, -1.0, 1.0;
788 mesh->createVertex(position);
789 position << -1.0, 0.0, 0.0;
790 mesh->createVertex(position);
791 position << -1.0, -1.0, 1.0;
792 mesh->createVertex(position);
793 position << -2.0, -0.0, 0.0;
794 mesh->createVertex(position);
795 position << -2.0, -1.0, 1.0;
796 mesh->createVertex(position);
798 Eigen::VectorXd position(dimensions);
799 position << 0.0, 0.0, 0.0;
800 mesh->createVertex(position);
801 position << 1.0, 0.0, 0.0;
802 mesh->createVertex(position);
803 position << 0.0, -1.0, 1.0;
804 mesh->createVertex(position);
805 position << 1.0, -1.0, 1.0;
806 mesh->createVertex(position);
807 position << 2.0, 0.0, 0.0;
808 mesh->createVertex(position);
809 position << 2.0, -1.0, 0.0;
810 mesh->createVertex(position);
813 mesh->computeBoundingBox();
815 if (context.isNamed(
"Solid")) {
816 m2n->createDistributedCommunication(
mesh);
820 part.compareBoundingBoxes();
822 if (context.isPrimary()) {
823 BOOST_TEST(
mesh->getConnectedRanks().size() == 2);
824 BOOST_TEST(
mesh->getConnectedRanks().at(0) == 0);
825 BOOST_TEST(
mesh->getConnectedRanks().at(1) == 1);
827 BOOST_TEST(
mesh->getConnectedRanks().size() == 2);
828 BOOST_TEST(
mesh->getConnectedRanks().at(0) == 0);
829 BOOST_TEST(
mesh->getConnectedRanks().at(1) == 1);
832 m2n->acceptSecondaryRanksPreConnection(
"FluidSecondaryRanks",
"SolidSecondaryRanks");
837 if (context.isPrimary()) {
838 BOOST_TEST(
mesh->getCommunicationMap().at(0).at(0) == 0);
839 BOOST_TEST(
mesh->getCommunicationMap().at(0).at(1) == 1);
841 BOOST_TEST(
mesh->getCommunicationMap().at(0).at(0) == 0);
842 BOOST_TEST(
mesh->getCommunicationMap().at(1).at(0) == 1);
843 BOOST_TEST(
mesh->getCommunicationMap().at(1).at(1) == 2);
846 m2n->createDistributedCommunication(receivedMesh);
849 boundingFromMapping->setMeshes(receivedMesh,
mesh);
850 boundingToMapping->setMeshes(
mesh, receivedMesh);
855 part.addFromMapping(boundingFromMapping);
856 part.addToMapping(boundingToMapping);
858 part.compareBoundingBoxes();
860 m2n->requestSecondaryRanksPreConnection(
"FluidSecondaryRanks",
"SolidSecondaryRanks");
BOOST_AUTO_TEST_CASE(testIQNIMVJPPWithSubsteps)
BOOST_AUTO_TEST_SUITE(PreProcess)
BOOST_AUTO_TEST_SUITE_END()
#define PRECICE_TEST_SETUP(...)
Creates and attaches a TestSetup to a Boost test case.
int getGlobalNumberOfVertices() const
std::size_t nVertices() const
Returns the number of vertices.
Vertex & vertex(VertexID id)
Mutable access to a vertex by VertexID.
const std::vector< Rank > & getConnectedRanks() const
Returns a vector of connected ranks.
const VertexOffsets & getVertexOffsets() const
void computeBoundingBox()
Computes the boundingBox for the vertices.
Edge & createEdge(Vertex &vertexOne, Vertex &vertexTwo)
Creates and initializes an Edge object.
Vertex & createVertex(const Eigen::Ref< const Eigen::VectorXd > &coords)
Creates and initializes a Vertex object.
EdgeContainer & edges()
Returns modifiable container holding all edges.
@ ON_SECONDARY_RANKS
Filter after communication on all secondary ranks.
Mapping using nearest neighboring vertices.
An axis-aligned bounding box around a (partition of a) mesh.
Linear edge of a mesh, defined by two Vertex objects.
Container and creator for meshes.
std::map< int, BoundingBox > BoundingBoxMap
int getGlobalIndex() const
Globally unique index.
void addM2N(m2n::PtrM2N m2n)
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)
void compareBoundingBoxes() override
Intersections between bounding boxes around each rank are computed.
A partition that is computed from a mesh received from another participant.
void communicate() override
The mesh is communicated between both primary ranks (if required)
void receiveBoundingBoxMap(Communication &communication, int rankSender, mesh::Mesh::BoundingBoxMap &bbm)
void sendConnectionMap(Communication &communication, int rankReceiver, const mesh::Mesh::ConnectionMap &cm)
contains the logic of the parallel communication between participants.
std::shared_ptr< Mapping > PtrMapping
provides Mesh, Data and primitives.
std::shared_ptr< Mesh > PtrMesh
@ Events
Require to initialize Event.
Main namespace of the precice library.