@@ -138,6 +138,7 @@ void MaterialPoints::migrate() {
138138 Kokkos::Timer timer;
139139 auto MPs2Elm = getData<MPF_Tgt_Elm_ID>();
140140 auto MPs2Proc = getData<MPF_Tgt_Proc_ID>();
141+ auto mpAppID = getData<polyMPO::MPF_MP_APP_ID>();
141142
142143 IntView new_elem (" new_elem" , MPs->capacity ());
143144 IntView new_process (" new_process" , MPs->capacity ());
@@ -148,11 +149,40 @@ void MaterialPoints::migrate() {
148149 if (mask) {
149150 new_elem (mp) = MPs2Elm (mp);
150151 new_process (mp) = MPs2Proc (mp);
152+ if (rank!=new_process (mp)){
153+ mpAppID (mp)=-1 ;
154+ printf (" Particle migrated and so its AppID is -1\n " );
155+ }
151156 }
152157 };
153158 parallel_for (setMigrationFields, " setMigrationFields" );
154159 MPs->migrate (new_elem, new_process);
155160
161+ // Since rebuilt
162+ mpAppID = getData<polyMPO::MPF_MP_APP_ID>();
163+ // Count MPs that have -1 appID, so that we can count no of MPs received
164+ Kokkos::View<int *> numReceivedMPs (" numReceivedMPs" , 1 );
165+ Kokkos::deep_copy (numReceivedMPs, 0 );
166+ auto countnewMPs = PS_LAMBDA (const int & e, const int & mp, const bool & mask) {
167+ if (mask){
168+ if (mpAppID (mp) == -1 )
169+ Kokkos::atomic_add (&numReceivedMPs (0 ), 1 );
170+ }
171+ };
172+ parallel_for (countnewMPs, " countReceivedPtcls" );
173+ Kokkos::fence ();
174+
175+ auto numReceivedMPs_host = Kokkos::create_mirror_view (numReceivedMPs);
176+ Kokkos::deep_copy (numReceivedMPs_host, numReceivedMPs);
177+ if (numReceivedMPs_host (0 ))
178+ std::cout <<" Rank " <<rank<<" received " <<numReceivedMPs_host (0 )<< " MPs \n " ;
179+
180+ std::vector<int > added_mpIDs (numReceivedMPs_host (0 ));
181+ for (int i=0 ; i<numReceivedMPs_host (0 ); i++){
182+ printf (" Trying to find an ID for a material point\n " );
183+ auto xx = getNextAppID ();
184+ }
185+
156186 if (getOpMode () == polyMPO::MP_DEBUG)
157187 printf (" Material point migration: %f\n " , timer.seconds ());
158188 pumipic::RecordTime (" PolyMPO_migrate" , timer.seconds ());
0 commit comments