55 * BSD license as described in the LICENSE file in the top-level directory.
66 */
77
8- #include < PCU.h>
98#include " apfMesh.h"
109#include " apfNumbering.h"
1110#include " apfNumberingClass.h"
1211#include " apfShape.h"
1312#include " apfFieldData.h"
1413#include < pcu_util.h>
1514#include < lionPrint.h>
16- //
1715#include < sstream>
1816#include < fstream>
1917#include < iostream>
@@ -47,7 +45,7 @@ static Count count(apf::Mesh *m, int dim)
4745{
4846 const int local = apf::countOwned (m, dim);
4947 int total = local;
50- PCU_Add_Ints (&total, 1 ); // size of total array
48+ m-> getPCU ()-> Add < int > (&total, 1 ); // size of total array
5149 return std::make_pair (total, local);
5250}
5351
@@ -290,7 +288,7 @@ void WriteFields(const CGNS &cgns, const std::vector<std::vector<apf::MeshEntity
290288 }
291289
292290 int size = data.size ();
293- PCU_Add_Ints (&size, 1 ); // size of total array
291+ m-> getPCU ()-> Add < int > (&size, 1 ); // size of total array
294292
295293 // oddness of the api
296294 rmin[1 ] = rmin[0 ];
@@ -505,7 +503,7 @@ CellElementReturn WriteElements(const CGNS &cgns, apf::Mesh *m, apf::GlobalNumbe
505503 m->end (cellIter);
506504 numbersByElementType[o] = counter;
507505 int total = counter;
508- PCU_Add_Ints (&total, 1 ); // size of total array
506+ m-> getPCU ()-> Add < int > (&total, 1 ); // size of total array
509507 globalNumbersByElementType[o] = total;
510508 }
511509 cgsize_t allTotal = std::accumulate (globalNumbersByElementType.begin (), globalNumbersByElementType.end (), 0 );
@@ -546,12 +544,12 @@ CellElementReturn WriteElements(const CGNS &cgns, apf::Mesh *m, apf::GlobalNumbe
546544 if (cgp_section_write (cgns.index , cgns.base , cgns.zone , name.c_str (), cgnsElementOrder[o], globalStart, globalEnd, 0 , §ionNumber)) // global start, end within the file for that element type
547545 cgp_error_exit ();
548546
549- std::vector<int > allNumbersForThisType (PCU_Comm_Peers (), 0 );
547+ std::vector<int > allNumbersForThisType (m-> getPCU ()-> Peers (), 0 );
550548 MPI_Allgather (&numbersByElementType[o], 1 , MPI_INT, allNumbersForThisType.data (), 1 ,
551- MPI_INT, PCU_Get_Comm ());
549+ MPI_INT, m-> getPCU ()-> GetMPIComm ());
552550
553551 cgsize_t num = 0 ;
554- for (int i = 0 ; i < PCU_Comm_Self (); i++)
552+ for (int i = 0 ; i < m-> getPCU ()-> Self (); i++)
555553 num += allNumbersForThisType[i];
556554
557555 cgsize_t elStart = globalStart + num;
@@ -635,7 +633,7 @@ void AddBocosToMainBase(const CGNS &cgns, const CellElementReturn &cellResults,
635633 int startOfBCBlock = startingLocation + 1 ;
636634 const int number = bc.second .size ();
637635 int total = number;
638- PCU_Add_Ints (&total, 1 ); // size of total array
636+ m-> getPCU ()-> Add < int > (&total, 1 ); // size of total array
639637 if (total > 0 )
640638 {
641639 const auto allEnd = startOfBCBlock + total - 1 ; // one-based
@@ -657,12 +655,12 @@ void AddBocosToMainBase(const CGNS &cgns, const CellElementReturn &cellResults,
657655 }
658656 }
659657
660- std::vector<int > allNumbersForThisType (PCU_Comm_Peers (), 0 );
658+ std::vector<int > allNumbersForThisType (m-> getPCU ()-> Peers (), 0 );
661659 MPI_Allgather (&number, 1 , MPI_INT, allNumbersForThisType.data (), 1 ,
662- MPI_INT, PCU_Get_Comm ());
660+ MPI_INT, m-> getPCU ()-> GetMPIComm ());
663661
664662 cgsize_t num = 0 ;
665- for (int i = 0 ; i < PCU_Comm_Self (); i++)
663+ for (int i = 0 ; i < m-> getPCU ()-> Self (); i++)
666664 num += allNumbersForThisType[i];
667665
668666 cgsize_t elStart = startOfBCBlock + num;
@@ -685,34 +683,34 @@ void AddBocosToMainBase(const CGNS &cgns, const CellElementReturn &cellResults,
685683 cacheEnd = allEnd;
686684 }
687685 }
688- std::vector<int > cacheStarts (PCU_Comm_Peers (), 0 );
686+ std::vector<int > cacheStarts (m-> getPCU ()-> Peers (), 0 );
689687 MPI_Allgather (&cacheStart, 1 , MPI_INT, cacheStarts.data (), 1 ,
690- MPI_INT, PCU_Get_Comm ());
691- std::vector<int > cacheEnds (PCU_Comm_Peers (), 0 );
688+ MPI_INT, m-> getPCU ()-> GetMPIComm ());
689+ std::vector<int > cacheEnds (m-> getPCU ()-> Peers (), 0 );
692690 MPI_Allgather (&cacheEnd, 1 , MPI_INT, cacheEnds.data (), 1 ,
693- MPI_INT, PCU_Get_Comm ());
691+ MPI_INT, m-> getPCU ()-> GetMPIComm ());
694692 return std::make_pair (cacheStarts, cacheEnds);
695693 };
696694
697- const auto globalElementList = [](const std::vector<cgsize_t > &bcList, std::vector<cgsize_t > &allElements) {
698- std::vector<int > sizes (PCU_Comm_Peers (), 0 ); // important initialiser
695+ const auto globalElementList = [&m ](const std::vector<cgsize_t > &bcList, std::vector<cgsize_t > &allElements) {
696+ std::vector<int > sizes (m-> getPCU ()-> Peers (), 0 ); // important initialiser
699697 const int l = bcList.size ();
700698 MPI_Allgather (&l, 1 , MPI_INT, sizes.data (), 1 ,
701- MPI_INT, PCU_Get_Comm ());
699+ MPI_INT, m-> getPCU ()-> GetMPIComm ());
702700
703701 int totalLength = 0 ;
704702 for (const auto &i : sizes)
705703 totalLength += i;
706704
707- std::vector<int > displacement (PCU_Comm_Peers (), -1 );
705+ std::vector<int > displacement (m-> getPCU ()-> Peers (), -1 );
708706 displacement[0 ] = 0 ;
709707 for (std::size_t i = 1 ; i < displacement.size (); i++)
710708 displacement[i] = displacement[i - 1 ] + sizes[i - 1 ];
711709
712710 allElements.resize (totalLength);
713711 MPI_Allgatherv (bcList.data (), bcList.size (), MPI_INT, allElements.data (),
714712 sizes.data (), displacement.data (), MPI_INT,
715- PCU_Get_Comm ());
713+ m-> getPCU ()-> GetMPIComm ());
716714 };
717715
718716 const auto doVertexBC = [&](const auto &iter) {
@@ -755,7 +753,7 @@ void AddBocosToMainBase(const CGNS &cgns, const CellElementReturn &cellResults,
755753 for (const auto &p : iter->second )
756754 {
757755 const auto se = BCEntityAdder (EdgeLoop, p, startingLocation);
758- for (int i = 0 ; i < PCU_Comm_Peers (); i++)
756+ for (int i = 0 ; i < m-> getPCU ()-> Peers (); i++)
759757 {
760758 PCU_ALWAYS_ASSERT_VERBOSE (se.first [i] == se.first [0 ], " Must all be the same " );
761759 PCU_ALWAYS_ASSERT_VERBOSE (se.second [i] == se.second [0 ], " Must all be the same " );
@@ -779,7 +777,7 @@ void AddBocosToMainBase(const CGNS &cgns, const CellElementReturn &cellResults,
779777 {
780778 const auto se = BCEntityAdder (FaceLoop, p, startingLocation);
781779
782- for (int i = 0 ; i < PCU_Comm_Peers (); i++)
780+ for (int i = 0 ; i < m-> getPCU ()-> Peers (); i++)
783781 {
784782 PCU_ALWAYS_ASSERT_VERBOSE (se.first [i] == se.first [0 ], " Must all be the same " );
785783 PCU_ALWAYS_ASSERT_VERBOSE (se.second [i] == se.second [0 ], " Must all be the same " );
@@ -1011,7 +1009,7 @@ void WriteCGNS(const char *prefix, apf::Mesh *m, const apf::CGNSBCMap &cgnsBCMap
10111009{
10121010 static_assert (std::is_same<cgsize_t , int >::value, " cgsize_t not compiled as int" );
10131011
1014- const auto myRank = PCU_Comm_Self ();
1012+ const auto myRank = m-> getPCU ()-> Self ();
10151013 const Count vertexCount = count (m, 0 );
10161014 const Count edgeCount = count (m, 1 );
10171015 const Count faceCount = count (m, 2 );
@@ -1031,7 +1029,7 @@ void WriteCGNS(const char *prefix, apf::Mesh *m, const apf::CGNSBCMap &cgnsBCMap
10311029 // PCU_Barrier();
10321030 // }
10331031
1034- PCU_Barrier ();
1032+ m-> getPCU ()-> Barrier ();
10351033 if (myRank == 0 )
10361034 {
10371035 std::cout << " *******Global Mesh Stats*****************\n " ;
@@ -1048,7 +1046,7 @@ void WriteCGNS(const char *prefix, apf::Mesh *m, const apf::CGNSBCMap &cgnsBCMap
10481046 sizes[2 ] = 0 ; // nodes are unsorted, as defined by api
10491047
10501048 // Copy communicator
1051- auto communicator = PCU_Get_Comm ();
1049+ auto communicator = m-> getPCU ()-> GetMPIComm ();
10521050 cgp_mpi_comm (communicator);
10531051 //
10541052 cgp_pio_mode (CGP_INDEPENDENT);
0 commit comments