5
5
* BSD license as described in the LICENSE file in the top-level directory.
6
6
*/
7
7
8
- #include < PCU.h>
9
8
#include " apfMesh.h"
10
9
#include " apfNumbering.h"
11
10
#include " apfNumberingClass.h"
12
11
#include " apfShape.h"
13
12
#include " apfFieldData.h"
14
13
#include < pcu_util.h>
15
14
#include < lionPrint.h>
16
- //
17
15
#include < sstream>
18
16
#include < fstream>
19
17
#include < iostream>
@@ -47,7 +45,7 @@ static Count count(apf::Mesh *m, int dim)
47
45
{
48
46
const int local = apf::countOwned (m, dim);
49
47
int total = local;
50
- PCU_Add_Ints (&total, 1 ); // size of total array
48
+ m-> getPCU ()-> Add < int > (&total, 1 ); // size of total array
51
49
return std::make_pair (total, local);
52
50
}
53
51
@@ -290,7 +288,7 @@ void WriteFields(const CGNS &cgns, const std::vector<std::vector<apf::MeshEntity
290
288
}
291
289
292
290
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
294
292
295
293
// oddness of the api
296
294
rmin[1 ] = rmin[0 ];
@@ -505,7 +503,7 @@ CellElementReturn WriteElements(const CGNS &cgns, apf::Mesh *m, apf::GlobalNumbe
505
503
m->end (cellIter);
506
504
numbersByElementType[o] = counter;
507
505
int total = counter;
508
- PCU_Add_Ints (&total, 1 ); // size of total array
506
+ m-> getPCU ()-> Add < int > (&total, 1 ); // size of total array
509
507
globalNumbersByElementType[o] = total;
510
508
}
511
509
cgsize_t allTotal = std::accumulate (globalNumbersByElementType.begin (), globalNumbersByElementType.end (), 0 );
@@ -546,12 +544,12 @@ CellElementReturn WriteElements(const CGNS &cgns, apf::Mesh *m, apf::GlobalNumbe
546
544
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
547
545
cgp_error_exit ();
548
546
549
- std::vector<int > allNumbersForThisType (PCU_Comm_Peers (), 0 );
547
+ std::vector<int > allNumbersForThisType (m-> getPCU ()-> Peers (), 0 );
550
548
MPI_Allgather (&numbersByElementType[o], 1 , MPI_INT, allNumbersForThisType.data (), 1 ,
551
- MPI_INT, PCU_Get_Comm ());
549
+ MPI_INT, m-> getPCU ()-> GetMPIComm ());
552
550
553
551
cgsize_t num = 0 ;
554
- for (int i = 0 ; i < PCU_Comm_Self (); i++)
552
+ for (int i = 0 ; i < m-> getPCU ()-> Self (); i++)
555
553
num += allNumbersForThisType[i];
556
554
557
555
cgsize_t elStart = globalStart + num;
@@ -635,7 +633,7 @@ void AddBocosToMainBase(const CGNS &cgns, const CellElementReturn &cellResults,
635
633
int startOfBCBlock = startingLocation + 1 ;
636
634
const int number = bc.second .size ();
637
635
int total = number;
638
- PCU_Add_Ints (&total, 1 ); // size of total array
636
+ m-> getPCU ()-> Add < int > (&total, 1 ); // size of total array
639
637
if (total > 0 )
640
638
{
641
639
const auto allEnd = startOfBCBlock + total - 1 ; // one-based
@@ -657,12 +655,12 @@ void AddBocosToMainBase(const CGNS &cgns, const CellElementReturn &cellResults,
657
655
}
658
656
}
659
657
660
- std::vector<int > allNumbersForThisType (PCU_Comm_Peers (), 0 );
658
+ std::vector<int > allNumbersForThisType (m-> getPCU ()-> Peers (), 0 );
661
659
MPI_Allgather (&number, 1 , MPI_INT, allNumbersForThisType.data (), 1 ,
662
- MPI_INT, PCU_Get_Comm ());
660
+ MPI_INT, m-> getPCU ()-> GetMPIComm ());
663
661
664
662
cgsize_t num = 0 ;
665
- for (int i = 0 ; i < PCU_Comm_Self (); i++)
663
+ for (int i = 0 ; i < m-> getPCU ()-> Self (); i++)
666
664
num += allNumbersForThisType[i];
667
665
668
666
cgsize_t elStart = startOfBCBlock + num;
@@ -685,34 +683,34 @@ void AddBocosToMainBase(const CGNS &cgns, const CellElementReturn &cellResults,
685
683
cacheEnd = allEnd;
686
684
}
687
685
}
688
- std::vector<int > cacheStarts (PCU_Comm_Peers (), 0 );
686
+ std::vector<int > cacheStarts (m-> getPCU ()-> Peers (), 0 );
689
687
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 );
692
690
MPI_Allgather (&cacheEnd, 1 , MPI_INT, cacheEnds.data (), 1 ,
693
- MPI_INT, PCU_Get_Comm ());
691
+ MPI_INT, m-> getPCU ()-> GetMPIComm ());
694
692
return std::make_pair (cacheStarts, cacheEnds);
695
693
};
696
694
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
699
697
const int l = bcList.size ();
700
698
MPI_Allgather (&l, 1 , MPI_INT, sizes.data (), 1 ,
701
- MPI_INT, PCU_Get_Comm ());
699
+ MPI_INT, m-> getPCU ()-> GetMPIComm ());
702
700
703
701
int totalLength = 0 ;
704
702
for (const auto &i : sizes)
705
703
totalLength += i;
706
704
707
- std::vector<int > displacement (PCU_Comm_Peers (), -1 );
705
+ std::vector<int > displacement (m-> getPCU ()-> Peers (), -1 );
708
706
displacement[0 ] = 0 ;
709
707
for (std::size_t i = 1 ; i < displacement.size (); i++)
710
708
displacement[i] = displacement[i - 1 ] + sizes[i - 1 ];
711
709
712
710
allElements.resize (totalLength);
713
711
MPI_Allgatherv (bcList.data (), bcList.size (), MPI_INT, allElements.data (),
714
712
sizes.data (), displacement.data (), MPI_INT,
715
- PCU_Get_Comm ());
713
+ m-> getPCU ()-> GetMPIComm ());
716
714
};
717
715
718
716
const auto doVertexBC = [&](const auto &iter) {
@@ -755,7 +753,7 @@ void AddBocosToMainBase(const CGNS &cgns, const CellElementReturn &cellResults,
755
753
for (const auto &p : iter->second )
756
754
{
757
755
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++)
759
757
{
760
758
PCU_ALWAYS_ASSERT_VERBOSE (se.first [i] == se.first [0 ], " Must all be the same " );
761
759
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,
779
777
{
780
778
const auto se = BCEntityAdder (FaceLoop, p, startingLocation);
781
779
782
- for (int i = 0 ; i < PCU_Comm_Peers (); i++)
780
+ for (int i = 0 ; i < m-> getPCU ()-> Peers (); i++)
783
781
{
784
782
PCU_ALWAYS_ASSERT_VERBOSE (se.first [i] == se.first [0 ], " Must all be the same " );
785
783
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
1011
1009
{
1012
1010
static_assert (std::is_same<cgsize_t , int >::value, " cgsize_t not compiled as int" );
1013
1011
1014
- const auto myRank = PCU_Comm_Self ();
1012
+ const auto myRank = m-> getPCU ()-> Self ();
1015
1013
const Count vertexCount = count (m, 0 );
1016
1014
const Count edgeCount = count (m, 1 );
1017
1015
const Count faceCount = count (m, 2 );
@@ -1031,7 +1029,7 @@ void WriteCGNS(const char *prefix, apf::Mesh *m, const apf::CGNSBCMap &cgnsBCMap
1031
1029
// PCU_Barrier();
1032
1030
// }
1033
1031
1034
- PCU_Barrier ();
1032
+ m-> getPCU ()-> Barrier ();
1035
1033
if (myRank == 0 )
1036
1034
{
1037
1035
std::cout << " *******Global Mesh Stats*****************\n " ;
@@ -1048,7 +1046,7 @@ void WriteCGNS(const char *prefix, apf::Mesh *m, const apf::CGNSBCMap &cgnsBCMap
1048
1046
sizes[2 ] = 0 ; // nodes are unsorted, as defined by api
1049
1047
1050
1048
// Copy communicator
1051
- auto communicator = PCU_Get_Comm ();
1049
+ auto communicator = m-> getPCU ()-> GetMPIComm ();
1052
1050
cgp_mpi_comm (communicator);
1053
1051
//
1054
1052
cgp_pio_mode (CGP_INDEPENDENT);
0 commit comments