Skip to content

Commit b98b69a

Browse files
committed
First commit to port
1 parent c87fa7f commit b98b69a

5 files changed

Lines changed: 49 additions & 0 deletions

File tree

src/pmpo_c.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,20 @@ void polympo_setSolveVelocityMesh_f(MPMesh_ptr p_mpmesh, const int nVertices, in
14481448
Kokkos::deep_copy(solveVelocity, h_solveVelocity);
14491449
}
14501450

1451+
void polympo_setIceAreaVertex_f(MPMesh_ptr p_mpmesh, const int nVertices, double* array){
1452+
//chech validity
1453+
checkMPMeshValid(p_mpmesh);
1454+
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh;
1455+
1456+
PMT_ALWAYS_ASSERT(p_mesh->getNumVertices()==nVertices);
1457+
//copy the host array to the device
1458+
auto iceArea = p_mesh->getMeshField<polyMPO::MeshF_VtxMass>();
1459+
auto h_iceArea = Kokkos::create_mirror_view(iceArea);
1460+
for(int i=0; i<nVertices; i++)
1461+
h_iceArea(i, 0) = array[i];
1462+
Kokkos::deep_copy(iceArea, h_iceArea);
1463+
}
1464+
14511465
void polympo_calculateStressDivergence_f(MPMesh_ptr p_mpmesh){
14521466
//chech validity
14531467
checkMPMeshValid(p_mpmesh);
@@ -1570,6 +1584,11 @@ void polympo_set_oceanStressCoefficient_f(MPMesh_ptr p_mpmesh, const int nVertic
15701584
Kokkos::deep_copy(oceanStressCoeff, h_oceanStressCoeff);
15711585
}
15721586

1587+
void polympo_calculate_oceanStressCoefficient_f(MPMesh_ptr p_mpmesh){
1588+
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh;
1589+
p_mesh->calcOceanStressCoeff();
1590+
}
1591+
15731592
void polympo_velocity_grid_solve_f(MPMesh_ptr p_mpmesh){
15741593
//Temporary grid Solve after calculateDivergence
15751594
auto p_mesh = ((polyMPO::MPMesh*)p_mpmesh)->p_mesh;

src/pmpo_c.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ void polympo_setElasticTimeStep_f(MPMesh_ptr p_mpmesh, const double elasticTimeS
106106
void polympo_setDynamicTimeStep_f(MPMesh_ptr p_mpmesh, const double dynamicTimeStep);
107107
void polympo_setSolveStressMesh_f(MPMesh_ptr p_mpmesh, const int nCells, int* array);
108108
void polympo_setSolveVelocityMesh_f(MPMesh_ptr p_mpmesh, const int nVertices, int* array);
109+
void polympo_setIceAreaVertex_f(MPMesh_ptr p_mpmesh, const int nVertices, double* array);
109110
void polympo_calculateStressDivergence_f(MPMesh_ptr p_mpmesh);
110111
void polympo_getStressDivergence_f(MPMesh_ptr p_mpmesh, const int nVertices, double* uArray, double* vArray);
111112
void polympo_setTotalMassVtx_f(MPMesh_ptr p_mpmesh, const int nVertices, double* array);
@@ -114,6 +115,7 @@ void polympo_set_surfaceTiltForce_f(MPMesh_ptr p_mpmesh, const int nVertices, do
114115
void polympo_set_totalMassVertexfVertex_f(MPMesh_ptr p_mpmesh, const int nVertices, double* array);
115116
void polympo_set_oceanStress_f(MPMesh_ptr p_mpmesh, const int nVertices, double* uArray, double* vArray);
116117
void polympo_set_oceanStressCoefficient_f(MPMesh_ptr p_mpmesh, const int nVertices, double* array);
118+
void polympo_calculate_oceanStressCoefficient_f(MPMesh_ptr p_mpmesh);
117119
void polympo_velocity_grid_solve_f(MPMesh_ptr p_mpmesh);
118120
void polympo_set_boundary_normal_vertex_f(MPMesh_ptr p_mpmesh, const int nComps, const int nVertices, double* uArray, double* vArray);
119121
void polympo_set_free_slip_bc_f(MPMesh_ptr p_mpmesh);

src/pmpo_fortran.f90

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,14 @@ subroutine polympo_setSolveVelocityMesh(mpMesh, nVertices, array) &
10111011
type(c_ptr), value :: array
10121012
end subroutine
10131013

1014+
subroutine polympo_setIceAreaVertex(mpMesh, nVertices, array) &
1015+
bind(C, NAME='polympo_setIceAreaVertex_f')
1016+
use :: iso_c_binding
1017+
type(c_ptr), value :: mpMesh
1018+
integer(c_int), value :: nVertices
1019+
type(c_ptr), value :: array
1020+
end subroutine
1021+
10141022
subroutine polympo_calculateStressDivergence(mpMesh) &
10151023
bind(C, NAME='polympo_calculateStressDivergence_f')
10161024
use :: iso_c_binding
@@ -1073,6 +1081,12 @@ subroutine polympo_set_oceanStressCoefficient(mpMesh, nVertices, array) &
10731081
type(c_ptr), value :: array
10741082
end subroutine
10751083

1084+
subroutine polympo_calculate_oceanStressCoefficient(mpMesh) &
1085+
bind(C, NAME='polympo_calculate_oceanStressCoefficient_f')
1086+
use :: iso_c_binding
1087+
type(c_ptr), value :: mpMesh
1088+
end subroutine
1089+
10761090
subroutine polympo_velocity_grid_solve(mpMesh) &
10771091
bind(C, NAME='polympo_velocity_grid_solve_f')
10781092
use :: iso_c_binding

src/pmpo_mesh.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,18 @@ namespace polyMPO{
157157
});
158158
}
159159

160+
void Mesh::calcOceanStressCoeff(){
161+
int numVerticesOwned = getNumVerticesOwned();
162+
auto iceAreaVtx = getMeshField<polyMPO::MeshF_VtxMass>();
163+
auto oceanStressCoeff = getMeshField<MeshF_OceanStressCoeff>();
164+
auto velocity = getMeshField<MeshF_Vel>();
165+
auto solve_velocity = getMeshField<MeshF_SolveVelocity>();
166+
167+
Kokkos::parallel_for("calcOceanStressCoeff", numVerticesOwned, KOKKOS_LAMBDA(const int vtx){
168+
if(solve_velocity(vtx) == 0) return;
169+
oceanStressCoeff(vtx, 0) = 0.00536 * 1026.0 * iceAreaVtx(vtx, 0) * sqrt(velocity(vtx, 0)*velocity(vtx, 0) + velocity(vtx, 1)*velocity(vtx, 1));
170+
});
171+
}
160172

161173
void Mesh::gridSolveGPU(){
162174
//Mesh Fields

src/pmpo_mesh.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ class Mesh {
271271
double getDynamicTimeStep(){
272272
return dynamicTimeStep_;
273273
}
274+
275+
void calcOceanStressCoeff();
274276
void gridSolveGPU();
275277
void aggregateDeluDyn();
276278
void applyFreeSlipBC();

0 commit comments

Comments
 (0)