@@ -450,60 +450,56 @@ inline void sphericalInterpolationDispVelIncr(MPMesh& mpMesh){
450450 auto mpField2 = p_MPs->getData <mpfIndex2>();
451451
452452 // Field required for calculting gnomonic projection of MPs
453+ bool use3DArea=false ;
453454 auto gnomProjVtx = p_mesh->getMeshField <polyMPO::MeshF_VtxGnomProj>();
454455 auto gnomProjElmCenter = p_mesh->getMeshField <polyMPO::MeshF_ElmCenterGnomProj>();
455456
456457 auto interpolation = PS_LAMBDA (const int & elm, const int & mp, const int & mask) {
457458 if (mask) {
458- Vec3d position3d (MPsPosition (mp, 0 ), MPsPosition (mp, 1 ), MPsPosition (mp, 2 ));
459- Vec3d v3d[maxVtxsPerElm + 1 ];
459+
460+ double basisByArea[maxVtxsPerElm] = {0.0 };
461+ initArray (basisByArea, maxVtxsPerElm, 0.0 );
460462 int numVtx = elm2VtxConn (elm, 0 );
461- for (int i = 1 ; i <= numVtx; i++) {
462- v3d[i-1 ][0 ] = vtxCoords (elm2VtxConn (elm, i) - 1 , 0 );
463- v3d[i-1 ][1 ] = vtxCoords (elm2VtxConn (elm, i) - 1 , 1 );
464- v3d[i-1 ][2 ] = vtxCoords (elm2VtxConn (elm, i) - 1 , 2 );
463+ Vec3d position3d (MPsPosition (mp, 0 ), MPsPosition (mp, 1 ), MPsPosition (mp, 2 ));
464+
465+ if (use3DArea){
466+ Vec3d v3d[maxVtxsPerElm + 1 ];
467+ for (int i = 1 ; i <= numVtx; i++) {
468+ v3d[i-1 ][0 ] = vtxCoords (elm2VtxConn (elm, i) - 1 , 0 );
469+ v3d[i-1 ][1 ] = vtxCoords (elm2VtxConn (elm, i) - 1 , 1 );
470+ v3d[i-1 ][2 ] = vtxCoords (elm2VtxConn (elm, i) - 1 , 2 );
471+ }
472+ v3d[numVtx][0 ] = vtxCoords (elm2VtxConn (elm,1 )-1 ,0 );
473+ v3d[numVtx][1 ] = vtxCoords (elm2VtxConn (elm,1 )-1 ,1 );
474+ v3d[numVtx][2 ] = vtxCoords (elm2VtxConn (elm,1 )-1 ,2 );
475+ getBasisByAreaGblFormSpherical (position3d, numVtx, v3d, radius, basisByArea);
476+ }
477+ else { // if using gnomonic Projection for weights
478+ double mpProjX, mpProjY;
479+ auto gnomProjElmCenter_sub = Kokkos::subview (gnomProjElmCenter, elm, Kokkos::ALL);
480+ computeGnomonicProjectionAtPoint (position3d, gnomProjElmCenter_sub, mpProjX, mpProjY);
481+ auto gnom_vtx_subview = Kokkos::subview (gnomProjVtx, elm, Kokkos::ALL, Kokkos::ALL);
482+ compute2DplanarTriangleArea (numVtx, gnom_vtx_subview, mpProjX, mpProjY, basisByArea);
465483 }
466- v3d[numVtx][0 ] = vtxCoords (elm2VtxConn (elm,1 )-1 ,0 );
467- v3d[numVtx][1 ] = vtxCoords (elm2VtxConn (elm,1 )-1 ,1 );
468- v3d[numVtx][2 ] = vtxCoords (elm2VtxConn (elm,1 )-1 ,2 );
469-
470- double basisByArea3d[maxVtxsPerElm] = {0.0 };
471- initArray (basisByArea3d, maxVtxsPerElm, 0.0 );
472-
473- getBasisByAreaGblFormSpherical (position3d, numVtx, v3d, radius, basisByArea3d);
474-
475- // if using gnomonic Projection for weights
476- double mpProjX, mpProjY;
477- auto gnomProjElmCenter_sub = Kokkos::subview (gnomProjElmCenter, elm, Kokkos::ALL);
478- computeGnomonicProjectionAtPoint (position3d, gnomProjElmCenter_sub, mpProjX, mpProjY);
479- auto gnom_vtx_subview = Kokkos::subview (gnomProjVtx, elm, Kokkos::ALL, Kokkos::ALL);
480- double basisByArea2D[maxVtxsPerElm] = {0.0 };
481-
482- compute2DplanarTriangleArea (numVtx, gnom_vtx_subview, mpProjX, mpProjY, basisByArea2D);
483484
484485 for (int entry=0 ; entry<numEntries1; entry++){
485486 double mpValue = 0.0 ;
486- for (int i=1 ; i<= numVtx; i++){
487- // mpValue += meshField1(elm2VtxConn(elm,i)-1,entry)*basisByArea3d[i-1];
488- mpValue += meshField1 (elm2VtxConn (elm,i)-1 ,entry)*basisByArea2D[i-1 ];
489- }
487+ for (int i=1 ; i<= numVtx; i++)
488+ mpValue += meshField1 (elm2VtxConn (elm,i)-1 ,entry)*basisByArea[i-1 ];
490489 mpField1 (mp,entry) = mpValue;
491490 }
492491
493492 for (int entry=0 ; entry<numEntries2; entry++){
494493 double mpValue = 0.0 ;
495- for (int i=1 ; i<= numVtx; i++){
496- // mpValue += meshField2(elm2VtxConn(elm,i)-1,entry)*basisByArea3d[i-1];
497- mpValue += meshField2 (elm2VtxConn (elm,i)-1 ,entry)*basisByArea2D[i-1 ];
498- }
494+ for (int i=1 ; i<= numVtx; i++)
495+ mpValue += meshField2 (elm2VtxConn (elm,i)-1 ,entry)*basisByArea[i-1 ];
499496 mpField2 (mp,entry) = mpValue;
500- }
501- }
502- };
497+ }
498+ }// mask
499+ };// lambda
503500 p_MPs->parallel_for (interpolation, " sphericalInterpolationMultiField" );
504501 pumipic::RecordTime (" PolyMPO_sphericalInterpolationDispVelIncr" , timer.seconds ());
505- }
506-
502+ }
507503
508504} // namespace polyMPO end
509505#endif
0 commit comments