Skip to content

Commit 4b6930f

Browse files
committed
All tests on remus pass
1 parent 607de99 commit 4b6930f

File tree

8 files changed

+39
-48
lines changed

8 files changed

+39
-48
lines changed

src/pmpo_MPMesh.cpp

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,16 @@ void MPMesh::CVTTrackingElmCenterBased(const int printVTPIndex){
128128
auto MPs2Proc = p_MPs->getData<MPF_Tgt_Proc_ID>();
129129
auto elm2Process = p_mesh->getElm2Process();
130130
auto elm2global = p_mesh->getElmGlobal();
131-
auto mpAppID = p_MPs->getData<polyMPO::MPF_MP_APP_ID>();
132131

133-
MPI_Comm comm = p_MPs->getMPIComm();
134-
int comm_rank;
135-
MPI_Comm_rank(comm, &comm_rank);
136-
137132
//Since Mesh is static print pnly for 1 time step
138-
if(printVTPIndex==0) {
139-
printVTP_mesh(comm_rank);
133+
if(printVTPIndex>=0) {
134+
printVTP_mesh(printVTPIndex);
140135
}
141136

142137
Vec3dView history("positionHistory",numMPs);
143138
Vec3dView resultLeft("positionResult",numMPs);
144139
Vec3dView resultRight("positionResult",numMPs);
145140
Vec3dView mpTgtPosArray("positionTarget",numMPs);
146-
Kokkos::View<int*> counter("counter",1);
147141

148142
auto CVTElmCalc = PS_LAMBDA(const int& elm, const int& mp, const int&mask){
149143
Vec3d MP(mpPositions(mp,0),mpPositions(mp,1),mpPositions(mp,2));
@@ -176,7 +170,8 @@ void MPMesh::CVTTrackingElmCenterBased(const int printVTPIndex){
176170

177171
if(closestElm<0){
178172
MPs2Elm(mp) = iElm;
179-
MPs2Proc(mp) = elm2Process(iElm);
173+
if (elm2Process.size() > 0)
174+
MPs2Proc(mp) = elm2Process(iElm);
180175
break;
181176
}else{
182177
iElm = closestElm;
@@ -194,31 +189,28 @@ void MPMesh::CVTTrackingElmCenterBased(const int printVTPIndex){
194189
Vec3d shift = dx.cross(r) * ((1.0-0.7)*dx.magnitude()/(dx.cross(r)).magnitude());
195190
Vec3d MPLeft = MParrow + shift;
196191
Vec3d MPRight = MParrow - shift;
197-
auto xx=Kokkos::atomic_fetch_add(&counter(0), 1);
198-
history(xx) = MP;
199-
resultLeft(xx) = MPLeft;
200-
resultRight(xx) = MPRight;
201-
mpTgtPosArray(xx) = MPnew;
192+
history(mp) = MP;
193+
resultLeft(mp) = MPLeft;
194+
resultRight(mp) = MPRight;
195+
mpTgtPosArray(mp) = MPnew;
202196
}
203197
}
204198
};
205199
p_MPs->parallel_for(CVTElmCalc,"CVTTrackingElmCenterBasedCalc");
206200

207-
if(printVTPIndex>=0 && numMPs>0){
201+
if(printVTPIndex>=0){
208202
Vec3dView::HostMirror h_history = Kokkos::create_mirror_view(history);
209203
Vec3dView::HostMirror h_resultLeft = Kokkos::create_mirror_view(resultLeft);
210204
Vec3dView::HostMirror h_resultRight = Kokkos::create_mirror_view(resultRight);
211205
Vec3dView::HostMirror h_mpTgtPos = Kokkos::create_mirror_view(mpTgtPosArray);
212-
Kokkos::View<int*>::HostMirror h_counter = Kokkos::create_mirror_view(counter);
213206

214207
Kokkos::deep_copy(h_history, history);
215208
Kokkos::deep_copy(h_resultLeft, resultLeft);
216209
Kokkos::deep_copy(h_resultRight, resultRight);
217210
Kokkos::deep_copy(h_mpTgtPos, mpTgtPosArray);
218-
Kokkos::deep_copy(h_counter, counter);
219211
// printVTP file
220212
char* fileOutput = (char *)malloc(sizeof(char) * 256);
221-
sprintf(fileOutput, "polyMPOCVTTrackingElmCenter_MPtracks_%d_%d.vtp", comm_rank, printVTPIndex);
213+
sprintf(fileOutput, "polyMPOCVTTrackingElmCenter_MPtracks_%d.vtp", printVTPIndex);
222214
FILE * pFile = fopen(fileOutput,"w");
223215
free(fileOutput);
224216
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);
@@ -378,7 +370,6 @@ void MPMesh::push(){
378370
bool anyIsMigrating = false;
379371
do {
380372
CVTTrackingElmCenterBased(); // move to Tgt_XYZ
381-
assert(cudaDeviceSynchronize() == cudaSuccess);
382373
p_MPs->updateMPSlice<MPF_Cur_Pos_XYZ, MPF_Tgt_Pos_XYZ>(); // Tgt_XYZ becomes Cur_XYZ
383374
p_MPs->updateMPSlice<MPF_Cur_Pos_Rot_Lat_Lon, MPF_Tgt_Pos_Rot_Lat_Lon>(); // Tgt becomes Cur
384375

src/pmpo_c.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ void polympo_createMPs_f(MPMesh_ptr p_mpmesh,
123123
}
124124
}
125125
auto elm2global = p_mesh->getElmGlobal();
126-
127126
auto mpsPerElm_d = create_mirror_view_and_copy(mpsPerElm, numElms);
128127
auto active_mp2Elm_d = create_mirror_view_and_copy(active_mp2Elm.data(), numActiveMPs);
129128
auto active_mpIDs_d = create_mirror_view_and_copy(active_mpIDs.data(), numActiveMPs);
@@ -1250,7 +1249,6 @@ void polympo_setOwningProc_f(MPMesh_ptr p_mpmesh, const int nCells, const int* a
12501249
void polympo_setElmGlobal_f(MPMesh_ptr p_mpmesh, const int nCells, const int* array){
12511250
checkMPMeshValid(p_mpmesh);
12521251
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh;
1253-
PMT_ALWAYS_ASSERT(p_mesh->meshEditable());
12541252
Kokkos::View<int*, Kokkos::HostSpace> arrayHost("arrayHost", nCells);
12551253
for (int i = 0; i < nCells; i++) {
12561254
arrayHost(i) = array[i] - 1; // TODO right now elmID offset is set after MPs initialized

src/pmpo_mesh.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ class Mesh {
163163
void setOwningProc(IntView owningProc) {PMT_ALWAYS_ASSERT(meshEdit_);
164164
owningProc_ = owningProc; }
165165

166-
void setElmGlobal(IntView globalElm) {PMT_ALWAYS_ASSERT(meshEdit_);
167-
globalElm_ = globalElm; }
166+
void setElmGlobal(IntView globalElm) {globalElm_ = globalElm;}
168167
IntView getElmGlobal();
169168

170169
void computeRotLatLonIncr();

test/testFortranCreateRebuildMPs.f90

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ subroutine createMPsTest(mpMesh, nCells, numMPs, mp2Elm, isMPActive, mpPosition)
2525
real(kind=MPAS_RKIND) :: ptOne = 0.1_MPAS_RKIND
2626
integer, parameter :: MP_ACTIVE = 1
2727
integer, parameter :: MP_INACTIVE = 0
28-
integer, dimension(:), pointer :: mpsPerElm, mp2Elm, isMPActive
28+
integer, dimension(:), pointer :: mpsPerElm, mp2Elm, isMPActive, globalElms
2929
real(kind=MPAS_RKIND), dimension(:,:), pointer :: mpPosition
3030

3131
isMPActive = MP_ACTIVE !no inactive MPs and some changed below
@@ -42,11 +42,13 @@ subroutine createMPsTest(mpMesh, nCells, numMPs, mp2Elm, isMPActive, mpPosition)
4242
end do
4343

4444
allocate(mpsPerElm(nCells))
45+
allocate(globalElms(nCells))
4546
mpsPerElm = 1 !all elements have 1 MP and some changed below
4647
mpsPerElm(1) = 0 !1st element has 0 MPs
4748
mpsPerElm(2) = 2 !2nd element has 2 MPs
4849
mpsPerElm(3) = 2 !3rd element has 2 MPs
4950

51+
call polympo_setElmGlobal(mpMesh, nCells, c_loc(globalElms))
5052
call polympo_createMPs(mpMesh,nCells,numMPs,c_loc(mpsPerElm),c_loc(mp2Elm),c_loc(isMPActive))
5153

5254
!set mp positions
@@ -80,6 +82,7 @@ subroutine createMPsTest(mpMesh, nCells, numMPs, mp2Elm, isMPActive, mpPosition)
8082

8183
!deallocate MP variables
8284
deallocate(mpsPerElm)
85+
deallocate(globalElms)
8386
end subroutine
8487

8588
subroutine rebuildMPsTests(mpMesh, numMPs, mp2Elm, isMPActive, mpPosition)

test/testFortranMPAdvection.f90

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ program main
218218
real(kind=MPAS_RKIND), dimension(:), pointer :: xCell, yCell, zCell
219219
integer, dimension(:,:), pointer :: verticesOnCell, cellsOnCell
220220
integer :: numMPs, numMPsCount, numPush
221-
integer, dimension(:), pointer :: mpsPerElm, mp2Elm, isMPActive, mp2Elm_new
221+
integer, dimension(:), pointer :: mpsPerElm, mp2Elm, isMPActive, mp2Elm_new, globalElms
222222
real(kind=MPAS_RKIND), dimension(:,:), pointer :: mpPosition, mpLatLon, mpPositions_new, mpLatLon_new
223223
integer, parameter :: MP_ACTIVE = 1
224224
integer, parameter :: MP_INACTIVE = 0
@@ -284,6 +284,7 @@ program main
284284

285285
allocate(lonCell(nCells))
286286
allocate(mpsPerElm(nCells))
287+
allocate(globalElms(nCells))
287288
allocate(mp2Elm(numMPs))
288289
allocate(mp2Elm_new(numMPs))
289290

@@ -301,6 +302,7 @@ program main
301302
mp2Elm(numMPsCount+1:numMPsCount+localNumMPs) = i
302303
mpsPerElm(i) = localNumMPs
303304
numMPsCount = numMPsCount + localNumMPs
305+
globalElms(i)=i
304306
end do
305307

306308
call assert(numMPsCount == numMPs, "num mps miscounted")
@@ -356,24 +358,11 @@ program main
356358
end do
357359

358360
call assert(numMPsCount == numMPs, "num mps miscounted")
359-
361+
call polympo_setElmGlobal(mpMesh, nCells, c_loc(globalElms))
360362
call polympo_createMPs(mpMesh,nCells,numMPs,c_loc(mpsPerElm),c_loc(mp2Elm),c_loc(isMPActive))
361363
call polympo_setMPRotLatLon(mpMesh,2,numMPs,c_loc(mpLatLon))
362364
call polympo_setMPPositions(mpMesh,3,numMPs,c_loc(mpPosition))
363-
364-
!Another advection test to test if material poins come back to the same position
365-
call runAdvectionTest2(mpMesh, numPush, latVertex, lonVertex, nEdgesOnCell, verticesOnCell, nVertices, sphereRadius)
366-
call polympo_getMPPositions(mpMesh, 3, numMPs, c_loc(mpPositions_new))
367-
call polympo_getMPRotLatLon(mpMesh, 2, numMPs, c_loc(mpLatLon_new))
368-
call polympo_getMPCurElmID(mpMesh, numMPS, c_loc(mp2Elm_new))
369-
370-
do i = 1, numMPs
371-
if ( abs(mpLatLon_new(2,i)-mpLatLon(2,i)) > max_push_diff ) then
372-
max_push_diff = abs(mpLatLon_new(2,i)-mpLatLon(2,i))
373-
end if
374-
end do
375-
call assert(max_push_diff.le.TOLERANCE_PUSH , "MPs donot come back check push!")
376-
365+
377366
if (testType == "API") then
378367
call runApiTest(mpMesh, numMPs, nVertices, nCells, numPush, mpLatLon, mpPosition, xVertex, yVertex, zVertex, latVertex)
379368
else if (testType == "MIGRATION") then
@@ -412,7 +401,7 @@ program main
412401
deallocate(isMPActive)
413402
deallocate(mpPosition)
414403
deallocate(mpLatLon)
415-
404+
deallocate(globalElms)
416405
stop
417406

418407
end program

test/testFortranMPAppIDs.f90

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ subroutine testAppIDPointer(mpMesh) &
4040
integer :: setMeshOption, setMPOption
4141
integer :: ierr, self
4242
integer :: mpi_comm_handle = MPI_COMM_WORLD
43-
integer, dimension(:), pointer :: mpsPerElm, mp2Elm, isMPActive
43+
integer, dimension(:), pointer :: mpsPerElm, mp2Elm, isMPActive, globalElms
4444
type(c_ptr) :: mpMesh
4545
integer :: nCells, numMPs, appID
4646
integer, parameter :: MP_ACTIVE = 1
@@ -56,16 +56,19 @@ subroutine testAppIDPointer(mpMesh) &
5656
setMeshOption = 1 !create a hard coded planar test mesh
5757
setMPOption = 0 !create an empty set of MPs
5858
mpMesh = polympo_createMPMesh(setMeshOption, setMPOption)
59-
6059
numMPs = 1
6160
allocate(mpsPerElm(nCells))
61+
allocate(globalElms(nCells))
6262
allocate(mp2Elm(numMPs))
6363
allocate(isMPActive(numMPs))
6464
call polympo_getMeshNumElms(mpMesh, nCells)
6565
mpsPerElm = 1
6666
mp2Elm = 1
6767
isMPActive = MP_ACTIVE
68+
!This is a dummy array of global Cell IDs for each mesh element
69+
call polympo_setElmGlobal(mpMesh, nCells, c_loc(globalElms))
6870
call polympo_createMPs(mpMesh, nCells, numMPs, c_loc(mpsPerElm), c_loc(mp2Elm), c_loc(isMPActive))
71+
print *, "Done here"
6972
call polympo_setMPICommunicator(mpMesh, mpi_comm_handle)
7073
! Set function and opaque data structure(list/queue) used to retrieve appIDS
7174
call polympo_setAppIDFunc(mpMesh, c_funloc(GetAppID), c_loc(queue));
@@ -74,9 +77,15 @@ subroutine testAppIDPointer(mpMesh) &
7477
call testAppIDPointer(mpMesh)
7578

7679
! Clean Up
80+
deallocate(mpsPerElm)
81+
deallocate(globalElms)
82+
deallocate(mp2Elm)
83+
deallocate(isMPActive)
84+
85+
7786
call polympo_deleteMPMesh(mpMesh)
7887
call queue_destroy(queue)
7988
call polympo_finalize()
8089
call mpi_finalize(ierr)
8190

82-
end program
91+
end program

test/testFortranMPReconstruction.f90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ program main
3232

3333
integer, dimension(:,:), pointer :: verticesOnCell, cellsOnCell
3434
integer :: numMPs, vID
35-
integer, dimension(:), pointer :: mpsPerElm, mp2Elm, isMPActive
35+
integer, dimension(:), pointer :: mpsPerElm, mp2Elm, isMPActive, globalElms
3636
real(kind=MPAS_RKIND), dimension(:,:), pointer :: mpPosition, mpLatLon
3737
real(kind=MPAS_RKIND), dimension(:,:), pointer :: mpMass, mpVel
3838
real(kind=MPAS_RKIND), dimension(:), pointer :: meshVtxMass, meshElmMass, meshVtxMass1
@@ -84,6 +84,7 @@ program main
8484
!createMPs
8585
numMPs = nCells
8686
allocate(mpsPerElm(nCells))
87+
allocate(globalElms(nCells))
8788
allocate(mp2Elm(numMPs))
8889
allocate(isMPActive(numMPs))
8990
allocate(mpPosition(3,numMPs))
@@ -109,7 +110,8 @@ program main
109110
mpPosition(2,i) = yCell(i)
110111
mpPosition(3,i) = zCell(i)
111112
end do
112-
113+
114+
call polympo_setElmGlobal(mpMesh, nCells, c_loc(globalElms))
113115
call polympo_createMPs(mpMesh,nCells,numMPs,c_loc(mpsPerElm),c_loc(mp2Elm),c_loc(isMPActive))
114116
call polympo_setMPICommunicator(mpMesh, mpi_comm_handle)
115117
call polympo_setMPRotLatLon(mpMesh,2,numMPs,c_loc(mpLatLon))
@@ -188,7 +190,7 @@ program main
188190
deallocate(meshElmMass)
189191
deallocate(meshVtxVelu)
190192
deallocate(meshVtxVelv)
191-
193+
deallocate(globalElms)
192194
stop
193195

194196
contains

test/testMPAppIDs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ void testAppIDPointer(MPMesh_ptr p_mpmesh) {
6767
PMT_ALWAYS_ASSERT(numAddedMPsAfter_h == numAddedMPs);
6868
}
6969

70-
#endif
70+
#endif

0 commit comments

Comments
 (0)