@@ -75,34 +75,33 @@ void polympo_createMPs_f(MPMesh_ptr p_mpmesh,
7575 // Find the total no of MPs across all ranks
7676 // And loop over all MPs and find the smallest element id associated across a MP
7777 int numActiveMPs = 0 ;
78- int minElmID = numElms+ 1 ;
78+ int minElmID = INT_MAX ;
7979 for (int i = 0 ; i < numMPs; i++) {
8080 if (isMPActive[i] == MP_ACTIVE) {
81- if (mp2Elm[i] < minElmID) {
81+ numActiveMPs++;
82+ if (mp2Elm[i] < minElmID)
8283 minElmID = mp2Elm[i];
83- numActiveMPs++;
84- }
8584 }
8685 }
87- printf (" Num Active MPs and minElmId %d %d\n " , numActiveMPs, minElmID);
88- long long globalNumActiveMPs = 0 ;
86+ int globalNumActiveMPs = 0 ;
8987 int globalMinElmID;
90- MPI_Allreduce (&numActiveMPs, &globalNumActiveMPs, 1 , MPI_LONG_LONG_INT , MPI_SUM, MPI_COMM_WORLD);
91- MPI_Allreduce (&minElmID, &globalMinElmID, 1 , MPI_INT, MPI_MIN, MPI_COMM_WORLD);
88+ MPI_Allreduce (&numActiveMPs, &globalNumActiveMPs, 1 , MPI_INT , MPI_SUM, MPI_COMM_WORLD);
89+ MPI_Allreduce (&minElmID, &globalMinElmID, 1 , MPI_INT, MPI_MIN, MPI_COMM_WORLD);
9290 PMT_ALWAYS_ASSERT (globalNumActiveMPs>0 );
9391
9492 // Loop over all mesh elements 0,1,... and find the first element that has an associated MP
95- int firstElmWithMPs=numElms+ 1 ;
93+ int firstElmWithMPs=INT_MAX ;
9694 for (int i=0 ; i<numElms; i++) {
9795 if (mpsPerElm[i]) {
9896 firstElmWithMPs = i;
9997 break ;
10098 }
10199 }
102- printf (" First elem with MP %d\n " , firstElmWithMPs);
103100 int globalFirstElmWithMPs;
104101 MPI_Allreduce (&firstElmWithMPs, &globalFirstElmWithMPs, 1 , MPI_INT, MPI_MIN, MPI_COMM_WORLD);
105102
103+ printf (" With a MP, globally smallest mesh elm %d and first elm %d \n " , globalMinElmID, globalFirstElmWithMPs);
104+
106105 int offset = -1 ;
107106 if (globalMinElmID-globalFirstElmWithMPs==1 ) {
108107 offset = 1 ;
@@ -123,26 +122,23 @@ void polympo_createMPs_f(MPMesh_ptr p_mpmesh,
123122 numActiveMPs++;
124123 }
125124 }
125+ auto elm2global = p_mesh->getElmGlobal ();
126126
127127 auto mpsPerElm_d = create_mirror_view_and_copy (mpsPerElm, numElms);
128128 auto active_mp2Elm_d = create_mirror_view_and_copy (active_mp2Elm.data (), numActiveMPs);
129129 auto active_mpIDs_d = create_mirror_view_and_copy (active_mpIDs.data (), numActiveMPs);
130130
131131 delete ((polyMPO::MPMesh*)p_mpmesh)->p_MPs ;
132132 ((polyMPO::MPMesh*)p_mpmesh)->p_MPs =
133- new polyMPO::MaterialPoints (numElms, numActiveMPs, mpsPerElm_d, active_mp2Elm_d, active_mpIDs_d);
133+ new polyMPO::MaterialPoints (numElms, numActiveMPs, mpsPerElm_d, active_mp2Elm_d, active_mpIDs_d, elm2global );
134134
135135 auto p_MPs = ((polyMPO::MPMesh*)p_mpmesh)->p_MPs ;
136136 p_MPs->setElmIDoffset (offset);
137137
138- assert (cudaDeviceSynchronize () == cudaSuccess);
139- MPI_Barrier (MPI_COMM_WORLD);
140- printf (" Foo1\n " );
141-
142138}
143139
144140void polympo_startRebuildMPs_f (MPMesh_ptr p_mpmesh,
145- const int numMPs, // total number of MPs which is GREATER than or equal to number of active MPs
141+ const int numMPs, // Total # MPs which is GREATER than or equal to number of active MPs
146142 const int * allMP2Elm,
147143 const int * addedMPMask) {
148144 checkMPMeshValid (p_mpmesh);
@@ -1046,6 +1042,23 @@ void polympo_setOwningProc_f(MPMesh_ptr p_mpmesh, const int nCells, const int* a
10461042 p_mesh->setOwningProc (owningProc);
10471043}
10481044
1045+ void polympo_setElmGlobal_f (MPMesh_ptr p_mpmesh, const int nCells, const int * array){
1046+ checkMPMeshValid (p_mpmesh);
1047+ auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh ;
1048+ PMT_ALWAYS_ASSERT (p_mesh->meshEditable ());
1049+ Kokkos::View<int *, Kokkos::HostSpace> arrayHost (" arrayHost" , nCells);
1050+ for (int i = 0 ; i < nCells; i++) {
1051+ arrayHost (i) = array[i] - 1 ; // Decrease each value by 1
1052+ }
1053+ // check the size
1054+ PMT_ALWAYS_ASSERT (nCells == p_mesh->getNumElements ());
1055+
1056+ Kokkos::View<int *> elmGlobal (" elmGlobal" ,nCells);
1057+ Kokkos::deep_copy (elmGlobal, arrayHost);
1058+ p_mesh->setElmGlobal (elmGlobal);
1059+ }
1060+
1061+
10491062void polympo_enableTiming_f (){
10501063 pumipic::EnableTiming ();
10511064}
0 commit comments