Skip to content

Commit 42e4c6d

Browse files
committed
Passed nVerticesOwned from MPAS
1 parent bc2061f commit 42e4c6d

6 files changed

Lines changed: 25 additions & 5 deletions

File tree

src/pmpo_MPMesh.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void MPMesh::calculateStressDivergence(){
102102

103103
//Mesh Information
104104
auto elm2VtxConn = p_mesh->getElm2VtxConn();
105-
int numVtx = p_mesh->getNumVertices();
105+
int numVtxOwned = p_mesh->getNumVerticesOwned();
106106
auto vtxCoords = p_mesh->getMeshField<polyMPO::MeshF_VtxCoords>();
107107
int numVertices = p_mesh->getNumVertices();
108108
auto tanLatVertexRotatedOverRadius = p_mesh->getMeshField<MeshF_TanLatVertexRotatedOverRadius>();
@@ -176,7 +176,7 @@ void MPMesh::calculateStressDivergence(){
176176
}
177177

178178
auto stressDivergence = p_mesh->getMeshField<MeshF_StressDivergence>();
179-
Kokkos::parallel_for("calculate_divergence", numVtx, KOKKOS_LAMBDA(const int vtx){
179+
Kokkos::parallel_for("calculate_divergence", numVtxOwned, KOKKOS_LAMBDA(const int vtx){
180180
double ramp = nearAnEdge_l(vtx);
181181
double invM = 1.0/vtxMatrixMass_l(vtx);
182182
invM = vtxMatrixMass_l(vtx) >1e-4 ? invM : 0;

src/pmpo_c.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,12 @@ void polympo_setMeshNumVtxs_f(MPMesh_ptr p_mpmesh, const int numVtxs){
814814
p_mesh->setMeshVtxBasedFieldSize();
815815
}
816816

817+
void polympo_setMeshNumVtxsOwned_f(MPMesh_ptr p_mpmesh, const int numVtxsOwned){
818+
checkMPMeshValid(p_mpmesh);
819+
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh;
820+
p_mesh->setNumVtxsOwned(numVtxsOwned);
821+
}
822+
817823
void polympo_getMeshNumVtxs_f(MPMesh_ptr p_mpmesh, int & numVtxs) {
818824
checkMPMeshValid(p_mpmesh); //chech vailidity
819825
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh;

src/pmpo_c.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ void polympo_setMeshGeomTypePlanar_f(MPMesh_ptr p_mpmesh);
6464
void polympo_setMeshGeomTypeSpherical_f(MPMesh_ptr p_mpmesh);
6565
void polympo_setMeshSphereRadius_f(MPMesh_ptr p_mpmesh, const double sphereRadius);
6666
void polympo_setMeshNumVtxs_f(MPMesh_ptr p_mpmesh, const int numVtxs);
67+
void polympo_setMeshNumVtxsOwned_f(MPMesh_ptr p_mpmesh, const int numVtxsOwned);
6768
void polympo_getMeshNumVtxs_f(MPMesh_ptr p_mpmesh, int & numVtxs);
6869
void polympo_setMeshNumElms_f(MPMesh_ptr p_mpmesh, const int numElms);
6970
void polympo_getMeshNumElms_f(MPMesh_ptr p_mpmesh, int & numElms);

src/pmpo_fortran.f90

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,15 @@ subroutine polympo_setMeshNumVtxs(mpMesh,numVtxs) &
522522
integer(c_int), value :: numVtxs
523523
end subroutine
524524

525+
526+
subroutine polympo_setMeshNumVtxsOwned(mpMesh,numVtxsOwned) &
527+
bind(C, NAME='polympo_setMeshNumVtxsOwned_f')
528+
use :: iso_c_binding
529+
type(c_ptr), value :: mpMesh
530+
integer(c_int), value :: numVtxsOwned
531+
end subroutine
532+
533+
525534
!---------------------------------------------------------------------------
526535
!> @brief get the number of mesh vertices
527536
!> @param mpMesh(in) mpMesh object

src/pmpo_mesh.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ namespace polyMPO{
156156
void Mesh::gridSolveGPU(){
157157
std::cout<<__FUNCTION__<<std::endl;
158158
//Mesh Fields
159-
int numVertices = getNumVertices();
159+
int numVerticesOwned = getNumVerticesOwned();
160160
auto totalMassVtx = getMeshField<MeshF_TotalMassVtx>();
161161
auto totalMassFVtx = getMeshField<MeshF_TotalMassFVtx>();
162162
auto airStress = getMeshField<MeshF_AirStress>();
@@ -171,7 +171,7 @@ namespace polyMPO{
171171
double sinOceanTurningAngle=0.0;
172172
double cosOceanTurningAngle=1.0;
173173

174-
Kokkos::parallel_for("SolveGridVelocity", numVertices, KOKKOS_LAMBDA(const int vtx){
174+
Kokkos::parallel_for("SolveGridVelocity", numVerticesOwned, KOKKOS_LAMBDA(const int vtx){
175175
if(solve_velocity(vtx) == 0) return;
176176
double a, b, c, d, s, rhs_u, rhs_v, denom ;
177177

@@ -195,7 +195,7 @@ namespace polyMPO{
195195
printf("Vtx %d F: %.15e %.15e %.15e %.15e %.15e %.15e %.15e %.15e %.15e \n", vtx, totalMassVtx(vtx,0), totalMassFVtx(vtx,0),
196196
airStress(vtx,0), airStress(vtx,1), surfaceTiltForce(vtx,0), surfaceTiltForce(vtx,1), oceanStress(vtx,0), oceanStress(vtx,1),
197197
oceanStressCoeff(vtx, 0));*/
198-
printf("Vtx %d V: %.15e %.15e \n", vtx, velocity(vtx,0), velocity(vtx,1));
198+
//printf("Vtx %d V: %.15e %.15e \n", vtx, velocity(vtx,0), velocity(vtx,1));
199199
}
200200
});
201201
}

src/pmpo_mesh.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class Mesh {
123123

124124
double sphereRadius_;
125125
int numVtxs_;
126+
int numVtxsOwned_;
126127
int numElms_;
127128
//IntView nEdgesPerElm_;
128129
IntVtx2ElmView elm2VtxConn_;
@@ -203,6 +204,7 @@ class Mesh {
203204
geom_type getGeomType() { return geomType_; }
204205
double getSphereRadius() { return sphereRadius_; }
205206
int getNumVertices() { return numVtxs_; }
207+
int getNumVerticesOwned() { return numVtxsOwned_; }
206208
int getNumElements() { return numElms_; }
207209
IntVtx2ElmView getElm2VtxConn() { return elm2VtxConn_; }
208210
IntElm2ElmView getElm2ElmConn() { return elm2ElmConn_; }
@@ -221,6 +223,8 @@ class Mesh {
221223
sphereRadius_ = sphereRadius;}
222224
void setNumVtxs(int numVtxs) {PMT_ALWAYS_ASSERT(meshEdit_);
223225
numVtxs_ = numVtxs;}
226+
void setNumVtxsOwned(int numVtxsOwned) {PMT_ALWAYS_ASSERT(meshEdit_);
227+
numVtxsOwned_ = numVtxsOwned;}
224228
void setNumElms(int numElms) {PMT_ALWAYS_ASSERT(meshEdit_);
225229
numElms_ = numElms;}
226230
void setElm2VtxConn(IntVtx2ElmView elm2VtxConn) {PMT_ALWAYS_ASSERT(meshEdit_);

0 commit comments

Comments
 (0)