@@ -128,15 +128,12 @@ void MPMesh::CVTTrackingElmCenterBased(const int printVTPIndex){
128128 auto elm2Process = p_mesh->getElm2Process ();
129129 auto elm2global = p_mesh->getElmGlobal ();
130130
131- if (printVTPIndex>=0 ) {
131+ static int count_mesh_print=0 ;
132+ if (printVTPIndex>=0 && count_mesh_print==0 ) {
132133 printVTP_mesh (printVTPIndex);
134+ count_mesh_print += 1 ;
133135 }
134136
135- Vec3dView history (" positionHistory" ,numMPs);
136- Vec3dView resultLeft (" positionResult" ,numMPs);
137- Vec3dView resultRight (" positionResult" ,numMPs);
138- Vec3dView mpTgtPosArray (" positionTarget" ,numMPs);
139-
140137 auto CVTElmCalc = PS_LAMBDA (const int & elm, const int & mp, const int &mask){
141138 Vec3d MP (mpPositions (mp,0 ),mpPositions (mp,1 ),mpPositions (mp,2 ));
142139 if (mask){
@@ -155,8 +152,7 @@ void MPMesh::CVTTrackingElmCenterBased(const int printVTPIndex){
155152 for (int i=1 ; i<=numConnElms; i++){
156153 int elmID = elm2ElmConn (iElm,i)-1 ;
157154
158- // New delta
159- Vec3d center (elmCenter (elmID, 0 ), elmCenter (elmID, 1 ), elmCenter (elmID, 2 ));
155+ Vec3d center (elmCenter (elmID, 0 ), elmCenter (elmID, 1 ), elmCenter (elmID, 2 ));
160156 delta = MPnew - center;
161157
162158 double neighborDistSq = delta[0 ]*delta[0 ] + delta[1 ]*delta[1 ] + delta[2 ]*delta[2 ];
@@ -167,69 +163,16 @@ void MPMesh::CVTTrackingElmCenterBased(const int printVTPIndex){
167163 }
168164 if (closestElm<0 ){
169165 MPs2Elm (mp) = iElm;
170- if (elm2Process.size () > 0 )
171- MPs2Proc (mp) = elm2Process (iElm);
166+ MPs2Proc (mp) = elm2Process (iElm);
172167 break ;
173168 }else {
174169 iElm = closestElm;
175170 }
176171 }
177- if (printVTPIndex>=0 && numMPs>0 ){
178- double d1 = dx[0 ];
179- double d2 = dx[2 ];
180- double d3 = dx[3 ];
181- double m1 = MP[0 ];
182- double m2 = MP[1 ];
183- double m3 = MP[2 ];
184- Vec3d MParrow = MP + dx*0.7 ;
185- Vec3d r = MPnew * (1.0 /MPnew.magnitude ());
186- Vec3d shift = dx.cross (r) * ((1.0 -0.7 )*dx.magnitude ()/(dx.cross (r)).magnitude ());
187- Vec3d MPLeft = MParrow + shift;
188- Vec3d MPRight = MParrow - shift;
189- history (mp) = MP;
190- resultLeft (mp) = MPLeft;
191- resultRight (mp) = MPRight;
192- mpTgtPosArray (mp) = MPnew;
193- }
194172 }
195173 };
196174 p_MPs->parallel_for (CVTElmCalc," CVTTrackingElmCenterBasedCalc" );
197175
198- if (printVTPIndex>=0 ){
199- Vec3dView::HostMirror h_history = Kokkos::create_mirror_view (history);
200- Vec3dView::HostMirror h_resultLeft = Kokkos::create_mirror_view (resultLeft);
201- Vec3dView::HostMirror h_resultRight = Kokkos::create_mirror_view (resultRight);
202- Vec3dView::HostMirror h_mpTgtPos = Kokkos::create_mirror_view (mpTgtPosArray);
203-
204- Kokkos::deep_copy (h_history, history);
205- Kokkos::deep_copy (h_resultLeft, resultLeft);
206- Kokkos::deep_copy (h_resultRight, resultRight);
207- Kokkos::deep_copy (h_mpTgtPos, mpTgtPosArray);
208- // printVTP file
209- char * fileOutput = (char *)malloc (sizeof (char ) * 256 );
210- sprintf (fileOutput, " polyMPOCVTTrackingElmCenter_MPtracks_%d.vtp" , printVTPIndex);
211- FILE * pFile = fopen (fileOutput," w" );
212- free (fileOutput);
213- fprintf (pFile, " <VTKFile type=\" PolyData\" version=\" 1.0\" byte_order=\" LittleEndian\" header_type=\" UInt64\" >\n <PolyData>\n <Piece NumberOfPoints=\" %d\" NumberOfVerts=\" 0\" NumberOfLines=\" %d\" NumberOfStrips=\" 0\" NumberOfPolys=\" 0\" >\n <Points>\n <DataArray type=\" Float32\" Name=\" Points\" NumberOfComponents=\" 3\" format=\" ascii\" >\n " ,numMPs*4 ,numMPs*2 );
214- for (int i=0 ; i<numMPs; i++){
215- fprintf (pFile," %f %f %f\n %f %f %f\n %f %f %f\n %f %f %f\n " ,
216- h_history (i)[0 ],h_history (i)[1 ],h_history (i)[2 ],
217- h_mpTgtPos (i)[0 ],h_mpTgtPos (i)[1 ],h_mpTgtPos (i)[2 ],
218- h_resultLeft (i)[0 ],h_resultLeft (i)[1 ],h_resultLeft (i)[2 ],
219- h_resultRight (i)[0 ],h_resultRight (i)[1 ],h_resultRight (i)[2 ]);
220- }
221- fprintf (pFile," </DataArray>\n </Points>\n <Lines>\n <DataArray type=\" Int64\" Name=\" connectivity\" format=\" ascii\" >\n " );
222- for (int i=0 ; i<numMPs*4 ; i+=4 ){
223- fprintf (pFile," %d %d\n %d %d %d\n " ,i,i+1 ,i+2 ,i+1 ,i+3 );
224- }
225- fprintf (pFile," </DataArray>\n <DataArray type=\" Int64\" Name=\" offsets\" format=\" ascii\" >\n " );
226- for (int i=0 ; i<numMPs*5 ; i+=5 ){
227- fprintf (pFile," %d\n %d\n " ,i+2 ,i+5 );
228- }
229- fprintf (pFile," </DataArray>\n </Lines>\n </Piece>\n </PolyData>\n </VTKFile>\n " );
230- fclose (pFile);
231- }
232-
233176 pumipic::RecordTime (" PolyMPO_CVTTrackingElmCenterBased" , timer.seconds ());
234177}
235178
@@ -322,49 +265,53 @@ bool getAnyIsMigrating(MaterialPoints* p_MPs, bool isMigrating) {
322265 return anyIsMigrating;
323266}
324267
268+ // Spehrical Interpolation and Push
325269void MPMesh::push_ahead (){
326270 Kokkos::Timer timer;
327271 // Latitude Longitude increment at mesh vertices and interpolate to particle position
328272 p_mesh->computeRotLatLonIncr ();
329273
330- // sphericalInterpolation<MeshF_RotLatLonIncr>(*this);
331- // Interploate mesh velocity increments to particle positions
332- // Note that the basis fucntions are created twice and so need to avoid redeundant clualtions
333- // Tried template lists Template_Type... maybe better option available
334- // Kokkos::fence();
335- // sphericalInterpolation<MeshF_OnSurfVeloIncr>(*this);
336-
274+ /*
275+ sphericalInterpolation<MeshF_RotLatLonIncr>(*this);
276+ Kokkos::fence();
277+ sphericalInterpolation<MeshF_OnSurfVeloIncr>(*this);
278+ */
279+
280+ // The current spherical interpolation accepts just one template but for multiple
281+ // fields the same weights can be used, maybe pass parameter list. Temporarily,
282+ // application specific the following function
337283 sphericalInterpolation1 (*this );
338284
339- // Push the MPs
285+ // Move the MPs
340286 p_MPs->updateRotLatLonAndXYZ2Tgt (p_mesh->getSphereRadius ());
341287 pumipic::RecordTime (" PolyMPO_interpolateAndPush" , timer.seconds ());
342288}
343289
290+ // MP Tracking and migration check
344291bool MPMesh::push1P (){
345292 Kokkos::Timer timer;
346293 // Given target location find the new element or the last element in a partioned mesh
347- // and the process it belongs to so that migration can be checked
294+ // for the MP. Also the owning process for that element.
348295 CVTTrackingElmCenterBased ();
349- // From the above two inputs find if any particle needs to be migrated
296+ // From the above check if any particle needs to be migrated
350297 bool anyIsMigrating = getAnyIsMigrating (p_MPs, p_MPs->check_migrate ());
351298 pumipic::RecordTime (" PolyMPO_trackAndCheckMigrate" , timer.seconds ());
352299 return anyIsMigrating;
353300}
354301
302+ // Current elm becomes the target elm, target elm becomes -1
355303void MPMesh::push_swap (){
356- // current becomes target, target becomes -1
357304 p_MPs->updateMPElmID ();
358305}
359306
307+ // Current becomes the target, target becomes -1
308+ // Make read for next push_ahead
360309void MPMesh::push_swap_pos (){
361- // current becomes target, target becomes -1
362- // Making read for next push_ahead
363310 p_MPs->updateMPSlice <MPF_Cur_Pos_XYZ, MPF_Tgt_Pos_XYZ>();
364311 p_MPs->updateMPSlice <MPF_Cur_Pos_Rot_Lat_Lon, MPF_Tgt_Pos_Rot_Lat_Lon>();
365312}
366313
367-
314+ // Push routine where migration is carried out using polyMPO
368315void MPMesh::push (){
369316
370317 Kokkos::Timer timer;
0 commit comments