Skip to content

Commit ed0dcaf

Browse files
committed
Two fields instead of 4 while doing stress divergence
1 parent b695be2 commit ed0dcaf

1 file changed

Lines changed: 14 additions & 31 deletions

File tree

src/pmpo_MPMesh.cpp

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ void MPMesh::calculateStress(){
8181

8282
auto setMPStress = PS_LAMBDA(const int& elm, const int& mp, const int& mask){
8383
if(mask){
84-
8584
Vec3d strain_rate (MPsStrainRate(mp, 0), MPsStrainRate(mp, 1), MPsStrainRate(mp, 2));
8685
Vec3d stress(MPsStress(mp, 0), MPsStress(mp, 1), MPsStress(mp, 2));
8786
constitutive_evp(strain_rate, stress, MPsIcePressure(mp, 0), MPsRepPressure(mp, 0), MPsArea(mp, 0), elasticTimeStep, dampingTimescale);
@@ -132,11 +131,8 @@ void MPMesh::calculateStressDivergence(){
132131
radius=p_mesh->getSphereRadius();
133132

134133
//Reconstructed the stress
135-
Kokkos::View<doubleSclr_t*> stress_divU("stress_divu", p_mesh->getNumVertices());
136-
Kokkos::View<doubleSclr_t*> stress_divV("stress_divv", p_mesh->getNumVertices());
137-
138-
Kokkos::View<doubleSclr_t*> divU_edge("divUedge", p_mesh->getNumVertices());
139-
Kokkos::View<doubleSclr_t*> divV_edge("divVedge", p_mesh->getNumVertices());
134+
Kokkos::View<vec2d_t*> stress_divUV("stress_divUV", p_mesh->getNumVertices());
135+
Kokkos::View<vec2d_t*> divUV_edge("divUVedge", p_mesh->getNumVertices());
140136

141137
//Assemble fields for Stress Divergence
142138
auto stress_div = PS_LAMBDA(const int& elm, const int& mp, const int& mask) {
@@ -160,51 +156,38 @@ void MPMesh::calculateStressDivergence(){
160156
VtxCoeffs_new(vID,2, 2)*CoordDiffs[2] +
161157
VtxCoeffs_new(vID,2, 3)*CoordDiffs[3]);
162158

163-
Kokkos::atomic_add(&stress_divU(vID, 0), factor1 * MPsStress(mp, 0) + factor2 * MPsStress(mp, 2) -
159+
Kokkos::atomic_add(&stress_divUV(vID, 0), factor1 * MPsStress(mp, 0) + factor2 * MPsStress(mp, 2) -
164160
2 * tanLatVertexRotatedOverRadius(vID, 0) * factor * MPsStress(mp, 2));
165-
Kokkos::atomic_add(&stress_divV(vID, 0), factor2 * MPsStress(mp, 1) + factor1*MPsStress(mp, 2) +
161+
Kokkos::atomic_add(&stress_divUV(vID, 1), factor2 * MPsStress(mp, 1) + factor1*MPsStress(mp, 2) +
166162
factor * tanLatVertexRotatedOverRadius(vID, 0) * (MPsStress(mp, 0)-MPsStress(mp, 1)));
167163

168-
169-
Kokkos::atomic_add(&divU_edge(vID, 0), - weight_grads(mp, i*2 + 0) * MPsStress(mp, 0) - weight_grads(mp, i*2 + 1) * MPsStress(mp, 2) -
164+
Kokkos::atomic_add(&divUV_edge(vID, 0), - weight_grads(mp, i*2 + 0) * MPsStress(mp, 0) - weight_grads(mp, i*2 + 1) * MPsStress(mp, 2) -
170165
2 * tanLatVertexRotatedOverRadius(vID, 0) * w_vtx * MPsStress(mp, 2));
171-
Kokkos::atomic_add(&divV_edge(vID, 0), - weight_grads(mp, i*2 + 1) * MPsStress(mp, 1) - weight_grads(mp, i*2 + 0) * MPsStress(mp, 2) +
166+
Kokkos::atomic_add(&divUV_edge(vID, 1), - weight_grads(mp, i*2 + 1) * MPsStress(mp, 1) - weight_grads(mp, i*2 + 0) * MPsStress(mp, 2) +
172167
w_vtx * tanLatVertexRotatedOverRadius(vID, 0) * (MPsStress(mp, 0)- MPsStress(mp, 1)));
173168

174169
}
175170
}
176171
};
177172
p_MPs->parallel_for(stress_div, " stress_div_assembly");
178173

179-
if(numProcsTot>1){
180-
174+
if(numProcsTot>1){
181175
//Takes contribution of halo vertices and adds it in owner procs
182-
communicate_and_take_halo_contributions(stress_divU, numVertices, 1, 0, 0);
183-
communicate_and_take_halo_contributions(stress_divV, numVertices, 1, 0, 0);
184-
communicate_and_take_halo_contributions(divU_edge, numVertices, 1, 0, 0);
185-
communicate_and_take_halo_contributions(divV_edge, numVertices, 1, 0, 0);
186-
//Does it need to transfer the correct values at owned vertices to halo vertices
187-
communicate_and_take_halo_contributions(stress_divU, numVertices, 1, 1, 1);
188-
communicate_and_take_halo_contributions(stress_divV, numVertices, 1, 1, 1);
189-
communicate_and_take_halo_contributions(divU_edge, numVertices, 1, 1, 1);
190-
communicate_and_take_halo_contributions(divV_edge, numVertices, 1, 1, 1);
191-
176+
communicate_and_take_halo_contributions(stress_divUV, numVertices, 2, 0, 0);
177+
communicate_and_take_halo_contributions(divUV_edge, numVertices, 2, 0, 0);
178+
//Transfer the correct values at owned vertices to halo vertices
179+
communicate_and_take_halo_contributions(stress_divUV, numVertices, 2, 1, 1);
180+
communicate_and_take_halo_contributions(divUV_edge, numVertices, 2, 1, 1);
192181
}
193182

194183
auto stressDivergence = p_mesh->getMeshField<MeshF_StressDivergence>();
195184
Kokkos::parallel_for("calculate_divergence", numVtx, KOKKOS_LAMBDA(const int vtx){
196-
197185
double ramp = nearAnEdge_l(vtx);
198186
double invM = 1.0/vtxMatrixMass_l(vtx);
199187
invM = vtxMatrixMass_l(vtx) >1e-4 ? invM : 0;
200188

201-
stressDivergence(vtx, 0) = ramp * stress_divU(vtx, 0) + (1 - ramp) * divU_edge(vtx, 0) * invM ;
202-
stressDivergence(vtx, 1) = ramp * stress_divV(vtx, 0) + (1 - ramp) * divV_edge(vtx, 0) * invM ;
203-
/*
204-
if (ent2global(vtx) == 1714) {
205-
printf("Vtx %d Divergence %.15e %.15e %.15e %.15e \n", vtx, stressDivergence(vtx, 0), stressDivergence(vtx, 1));
206-
}
207-
*/
189+
stressDivergence(vtx, 0) = ramp * stress_divUV(vtx, 0) + (1 - ramp) * divUV_edge(vtx, 0) * invM ;
190+
stressDivergence(vtx, 1) = ramp * stress_divUV(vtx, 1) + (1 - ramp) * divUV_edge(vtx, 1) * invM ;
208191
});
209192
}
210193

0 commit comments

Comments
 (0)