Skip to content

Commit 189d00a

Browse files
committed
Ctests passing in remus
1 parent 59f056a commit 189d00a

File tree

7 files changed

+53
-37
lines changed

7 files changed

+53
-37
lines changed

src/pmpo_MPMesh_assembly.hpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ DoubleView MPMesh::assemblyV0(){
2828
template <MeshFieldIndex meshFieldIndex>
2929
void MPMesh::assemblyVtx0(){
3030
Kokkos::Timer timer;
31+
3132
constexpr MaterialPointSlice mpfIndex = meshFieldIndexToMPSlice<meshFieldIndex>;
3233
auto elm2VtxConn = p_mesh->getElm2VtxConn();
3334
auto mpData = p_MPs->getData<mpfIndex>();
@@ -94,7 +95,8 @@ void MPMesh::assemblyElm0() {
9495
pumipic::RecordTime("PolyMPO_Reconstruct_Elm0", timer.seconds());
9596
}
9697

97-
void MPMesh::reconstruct_coeff_full(){
98+
void MPMesh::reconstruct_coeff_full(){
99+
std::cout<<__FUNCTION__<<std::endl;
98100
Kokkos::Timer timer;
99101
int self, numProcsTot;
100102
MPI_Comm comm = p_MPs->getMPIComm();
@@ -142,7 +144,7 @@ void MPMesh::reconstruct_coeff_full(){
142144
Kokkos::atomic_add(&vtxMatrices(vID,6), w_vtx*(-vtxCoords(vID,0)+mpPos(mp,0))*(-vtxCoords(vID,2)+mpPos(mp,2))/(radius*radius));
143145
Kokkos::atomic_add(&vtxMatrices(vID,7), w_vtx*(-vtxCoords(vID,1)+mpPos(mp,1))*(-vtxCoords(vID,1)+mpPos(mp,1))/(radius*radius));
144146
Kokkos::atomic_add(&vtxMatrices(vID,8), w_vtx*(-vtxCoords(vID,1)+mpPos(mp,1))*(-vtxCoords(vID,2)+mpPos(mp,2))/(radius*radius));
145-
Kokkos::atomic_add(&vtxMatrices(vID,9), w_vtx*(-vtxCoords(vID,2)+mpPos(mp,2))*(-vtxCoords(vID,2)+mpPos(mp,2))/(radius*radius));
147+
Kokkos::atomic_add(&vtxMatrices(vID,9), w_vtx*(-vtxCoords(vID,2)+mpPos(mp,2))*(-vtxCoords(vID,2)+mpPos(mp,2))/(radius*radius));
146148
}
147149
}
148150
};
@@ -278,9 +280,9 @@ void MPMesh::invertMatrix(const Kokkos::View<double**>& vtxMatrices, const doubl
278280
VtxCoeffs(vtx, 0, 2) = temp[1];
279281
VtxCoeffs(vtx, 0, 3) = temp[2];
280282

281-
//Debugging
283+
//Debugging
282284
/*
283-
if(vtx == 2630){
285+
if(vtx == 10){
284286
printf("Matrices %d vtx \n", vtx);
285287
printf("[ %.15e %.15e %.15e %.15e ]\n", vtxMatrices(vtx,0), vtxMatrices(vtx,1), vtxMatrices(vtx,2), vtxMatrices(vtx,3));
286288
printf("[ %.15e %.15e %.15e %.15e ]\n", vtxMatrices(vtx,1), vtxMatrices(vtx,4), vtxMatrices(vtx,5), vtxMatrices(vtx,6));
@@ -306,6 +308,7 @@ void MPMesh::invertMatrix(const Kokkos::View<double**>& vtxMatrices, const doubl
306308

307309
template <MeshFieldIndex meshFieldIndex>
308310
void MPMesh::assemblyVtx1() {
311+
std::cout<<__FUNCTION__<<std::endl;
309312
Kokkos::Timer timer;
310313

311314
int self, numProcsTot;
@@ -368,22 +371,23 @@ void MPMesh::assemblyVtx1() {
368371
communicate_and_take_halo_contributions(meshField, numVertices, numEntries, 0, 0);
369372
pumipic::RecordTime("Communicate Field Values" + std::to_string(self), timer.seconds());
370373

371-
//Debug
372-
//Kokkos::fence();
373-
//assert(cudaDeviceSynchronize() == cudaSuccess);
374+
//Debugging
375+
/*
376+
assert(cudaDeviceSynchronize() == cudaSuccess);
374377
Kokkos::parallel_for("printSymmetricBlock", numVertices, KOKKOS_LAMBDA(const int vtx){
375378
if (vtx >= 10 && vtx <= 10) {
376379
printf("Field in %d: ", vtx);
377380
for (int k=0; k<numEntries; k++)
378381
printf(" %.15e ", meshField(vtx, k));
379382
printf("\n");
380383
}
381-
});
384+
});
385+
*/
382386
}
383387

384388
//Start Communication routine
385389
void MPMesh::startCommunication(){
386-
390+
std::cout<<__FUNCTION__<<std::endl;
387391
Kokkos::Timer timer;
388392
int self, numProcsTot;
389393
MPI_Comm comm = p_MPs->getMPIComm();
@@ -431,7 +435,7 @@ void MPMesh::startCommunication(){
431435
ent2global);
432436

433437
//Do Map of Global To Local ID
434-
//TODO make ordered map; which faster?
438+
//Check unordered vs ordered map; which faster?
435439
std::map<int, int> global2local;
436440
//std::unordered_map<int, int> global2local;
437441
for (int iEnt = 0; iEnt < numEntities; iEnt++) {
@@ -527,12 +531,7 @@ void MPMesh::startCommunication(){
527531

528532
pumipic::RecordTime("Start Communication" + std::to_string(self), timer.seconds());
529533

530-
bool isRotated = p_mesh->getRotatedFlag();
531-
p_mesh->setGnomonicProjection(isRotated);
532-
533534
/*
534-
if (p_MPs->getOpMode() != polyMPO::MP_DEBUG)
535-
return;
536535
printf("Rank %d Owners %d Halos %d Total %d \n", self, numOwnersTot, numHalosTot, numEntities);
537536
for (int i=0; i<numProcsTot; i++){
538537
printf("Rank %d has %d halos which are owners in other rank %d \n", self, numOwnersOnOtherProcs[i], i);
@@ -757,8 +756,6 @@ void MPMesh::communicateFields(const std::vector<std::vector<double>>& fieldData
757756
MPI_Waitall(requests.size(), requests.data(), MPI_STATUSES_IGNORE);
758757

759758
/*
760-
if (p_MPs->getOpMode() != polyMPO::MP_DEBUG)
761-
return;
762759
static int count_deb=0;
763760
if(self==0) std::cout<<"====================="<<count_deb<<"========================"<<std::endl;
764761
count_deb++;

src/pmpo_c.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,13 @@ void polympo_getMeshDualTriangleArea_f(MPMesh_ptr p_mpmesh, const int nVertices,
11991199
areaTriangle[i] = h_dualArea(i,0);
12001200
}
12011201

1202+
void polympo_setGnomonicProjection_f(MPMesh_ptr p_mpmesh){
1203+
checkMPMeshValid(p_mpmesh);
1204+
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh;
1205+
bool isRotated = p_mesh->getRotatedFlag();
1206+
p_mesh->setGnomonicProjection(isRotated);
1207+
}
1208+
12021209
void polyMPO_setTanLatVertexRotatedOverRadius_f(MPMesh_ptr p_mpmesh, const int nVertices, double* array){
12031210
//chech validity
12041211
checkMPMeshValid(p_mpmesh);

src/pmpo_c.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ void polympo_setMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, const dou
9393
void polympo_getMeshElmCenter_f(MPMesh_ptr p_mpmesh, const int nCells, double* xArray, double* yArray, double* zArray);
9494
void polympo_setMeshDualTriangleArea_f(MPMesh_ptr p_mpmesh, const int nVertices, const double* areaTriangle);
9595
void polympo_getMeshDualTriangleArea_f(MPMesh_ptr p_mpmesh, const int nVertices, double* areaTriangle);
96+
void polympo_setGnomonicProjection_f(MPMesh_ptr p_mpmesh);
9697
void polyMPO_setTanLatVertexRotatedOverRadius_f(MPMesh_ptr p_mpmesh, const int nVertices, double* array);
9798

9899
// Advection calculations

src/pmpo_fortran.f90

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -885,16 +885,21 @@ subroutine polympo_getMeshDualTriangleArea(mpMesh, nVertices, areaTriangle) &
885885
integer(c_int), value :: nVertices
886886
type(c_ptr), value :: areaTriangle
887887
end subroutine
888-
888+
889+
subroutine polympo_setGnomonicProjection(mpMesh) &
890+
bind(C, NAME='polympo_setGnomonicProjection_f')
891+
use :: iso_c_binding
892+
type(c_ptr), value :: mpMesh
893+
end subroutine
894+
889895
subroutine polyMPO_setTanLatVertexRotatedOverRadius(mpMesh, nVertices, array) &
890-
bind(C, NAME=' polyMPO_setTanLatVertexRotatedOverRadius_f')
896+
bind(C, NAME=' polyMPO_setTanLatVertexRotatedOverRadius_f')
891897
use :: iso_c_binding
892898
type(c_ptr), value :: mpMesh
893899
integer(c_int), value :: nVertices
894900
type(c_ptr), value :: array
895901
end subroutine
896902

897-
898903
!---------------------------------------------------------------------------
899904
!> @brief calculate the MPs from given mesh vertices rotational latitude
900905
!> longitude, update the MP slices

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ else()
112112
endif()
113113
pmpo_add_test(testFortranReadMPAS 1 ./testFortranReadMPAS ${TEST_NC_FILE})
114114
pmpo_add_test(testFortranCreateRebuildMPs 1 ./testFortranCreateRebuildMPs ${TEST_NC_FILE})
115-
#pmpo_add_test(testFortranMPReconstruction 1 ./testFortranMPReconstruction ${TEST_NC_FILE})
115+
pmpo_add_test(testFortranMPReconstruction 1 ./testFortranMPReconstruction ${TEST_NC_FILE})
116116

117117
pmpo_add_test(test_timing 1 ./timeAssmblyWachspress 1 ${TEST_NC_FILE})
118118
pmpo_add_test(test_wachspress 1 ./testWachspress ${TEST_NC_FILE})

test/testFortranMPAdvection.f90

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,16 @@ subroutine runReconstructionTest(mpMesh, numMPs, numPush, nCells, nVertices, mp2
109109
call polympo_setMPMass(mpMesh,1,numMPs,c_loc(mpMass))
110110
call polympo_setMPVel(mpMesh,2,numMPs,c_loc(mpVel))
111111

112+
! Although this test just does 0th order reconstruction testing, and just needs the BasisSlice,
113+
! calculating the coefficeints too as that will involve calculating the Basis Slice
114+
call polympo_reconstruct_coeff_with_MPI(mpmesh)
112115
! Test push reconstruction
113-
114116
do j = 1, numPush
115117
call calcSurfDispIncr(mpMesh, latVertex, lonVertex, nEdgesOnCell, verticesOnCell, nVertices, sphereRadius)
116118
call polympo_setReconstructionOfMass(mpMesh,0,polympo_getMeshFElmType())
117119
call polympo_setReconstructionOfMass(mpMesh,0,polympo_getMeshFVtxType())
118120
call polympo_setReconstructionOfVel(mpMesh,0,polympo_getMeshFVtxType())
121+
call polympo_applyReconstruction(mpMesh)
119122
call polympo_push(mpMesh)
120123
call polympo_getMeshElmMass(mpMesh,nCells,c_loc(meshElmMass))
121124
call polympo_getMeshVtxMass(mpMesh,nVertices,c_loc(meshVtxMass))
@@ -270,7 +273,8 @@ program main
270273
latVertex, &
271274
xCell, yCell, zCell, &
272275
verticesOnCell, cellsOnCell)
273-
276+
277+
call polympo_setGnomonicProjection(mpMesh)
274278
call polympo_setMPICommunicator(mpMesh, mpi_comm_handle);
275279

276280
!createMPs

test/testFortranMPReconstruction.f90

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ program main
7878
latVertex, &
7979
xCell, yCell, zCell, &
8080
verticesOnCell, cellsOnCell, areaTriangle)
81-
81+
82+
call polympo_setGnomonicProjection(mpMesh)
8283
nCompsDisp = 2
8384
allocate(dispIncr(nCompsDisp,nVertices))
8485
!createMPs
@@ -120,29 +121,30 @@ program main
120121
call polympo_setMPMass(mpMesh,1,numMPs,c_loc(mpMass))
121122
call polympo_setMPVel(mpMesh,2,numMPs,c_loc(mpVel))
122123

123-
! Test vtx reconstruction
124-
call polympo_setReconstructionOfMass(mpMesh,0,polympo_getMeshFVtxType())
125-
call polympo_applyReconstruction(mpMesh)
126-
call polympo_getMeshVtxMass(mpMesh,nVertices,c_loc(meshVtxMass))
127-
128-
do i = 1, nVertices
129-
call assert(meshVtxMass(i) < TEST_VAL+TOLERANCE .and. meshVtxMass(i) > TEST_VAL-TOLERANCE, "Error: wrong vtx mass")
130-
!write(*, *) 'The value of LRV is:', meshVtxMass(i)
131-
end do
132-
124+
!First Order reconstruction done before 0th order reconstruction as calculation of coefficients will
125+
!fill the MpBasis slice
133126
!Test vtx order 1 reconstruction
127+
call polympo_reconstruct_coeff_with_MPI(mpmesh)
134128
call polympo_setReconstructionOfMass(mpMesh,1,polympo_getMeshFVtxType())
135129
call polympo_setReconstructionOfVel(mpMesh, 1, polympo_getMeshFVtxType())
136130
call polympo_applyReconstruction(mpMesh)
137131
call polympo_getMeshVtxMass(mpMesh,nVertices,c_loc(meshVtxMass1))
138132
call polympo_getMeshVtxVel(mpMesh, nVertices, c_loc(meshVtxVelu), c_loc(meshVtxVelv))
139133
do i = 1, nVertices
140134
call assert(meshVtxMass1(i) < TEST_VAL+TOLERANCE1 .and. meshVtxMass1(i) > TEST_VAL-TOLERANCE1, "Error: wrong vtx mass order 1")
141-
call assert(meshVtxVelu(i) < TEST_VAL+TOLERANCE1 .and. meshVtxVelu(i) > TEST_VAL-TOLERANCE1, "Error: wrong vtx velU order 1")
142-
call assert(meshVtxVelv(i) < TEST_VAL+TOLERANCE1 .and. meshVtxVelv(i) > TEST_VAL-TOLERANCE1, "Error: wrong vtx velV order 1")
143-
write(*, *) 'The value of LRV is:', meshVtxVelu(i)-TEST_VAL, meshVtxVelv(i)-TEST_VAL
135+
call assert(meshVtxVelu(i) < TEST_VAL+TOLERANCE1 .and. meshVtxVelu(i) > TEST_VAL-TOLERANCE1, "Error: wrong vtx velU order 1")
136+
call assert(meshVtxVelv(i) < TEST_VAL+TOLERANCE1 .and. meshVtxVelv(i) > TEST_VAL-TOLERANCE1, "Error: wrong vtx velV order 1")
144137
end do
145138

139+
! Test vtx order 0 reconstruction
140+
call polympo_setReconstructionOfMass(mpMesh,0,polympo_getMeshFVtxType())
141+
call polympo_applyReconstruction(mpMesh)
142+
call polympo_getMeshVtxMass(mpMesh,nVertices,c_loc(meshVtxMass))
143+
144+
do i = 1, nVertices
145+
call assert(meshVtxMass(i) < TEST_VAL+TOLERANCE .and. meshVtxMass(i) > TEST_VAL-TOLERANCE, "Error: wrong vtx mass")
146+
end do
147+
146148

147149
! Test push reconstruction
148150
do j = 1, 5

0 commit comments

Comments
 (0)