Skip to content

Commit

Permalink
TestSubcycling: fill wstate using Yfs
Browse files Browse the repository at this point in the history
  • Loading branch information
lwJi committed Apr 11, 2024
1 parent 48988eb commit a6b5a3e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
20 changes: 12 additions & 8 deletions TestSubcyclingMC/schedule.ccl
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ SCHEDULE TestSubcyclingMC_CalcY1 IN TestSubcyclingMC_RK4Group
READS: ustate(interior)
WRITES: pstate(interior)
# calculate Y1
WRITES: wstate(interior)
SYNC: wstate
READS: Y1(everywhere)
WRITES: wstate(everywhere)
#SYNC: wstate
} "calc Y1"

SCHEDULE TestSubcyclingMC_CalcY2 IN TestSubcyclingMC_RK4Group AFTER TestSubcyclingMC_CalcY1
Expand All @@ -37,8 +38,9 @@ SCHEDULE TestSubcyclingMC_CalcY2 IN TestSubcyclingMC_RK4Group AFTER TestSubcycli
WRITES: ustate(interior)
# calculate Y2
READS: pstate(interior)
WRITES: wstate(interior)
SYNC: wstate
READS: Y2(everywhere)
WRITES: wstate(everywhere)
#SYNC: wstate
} "calc Y2"

SCHEDULE TestSubcyclingMC_CalcY3 IN TestSubcyclingMC_RK4Group AFTER TestSubcyclingMC_CalcY2
Expand All @@ -52,8 +54,9 @@ SCHEDULE TestSubcyclingMC_CalcY3 IN TestSubcyclingMC_RK4Group AFTER TestSubcycli
WRITES: ustate(interior)
# calculate Y3
READS: pstate(interior)
WRITES: wstate(interior)
SYNC: wstate
READS: Y3(everywhere)
WRITES: wstate(everywhere)
#SYNC: wstate
} "calc Y3"

SCHEDULE TestSubcyclingMC_CalcY4 IN TestSubcyclingMC_RK4Group AFTER TestSubcyclingMC_CalcY3
Expand All @@ -67,8 +70,9 @@ SCHEDULE TestSubcyclingMC_CalcY4 IN TestSubcyclingMC_RK4Group AFTER TestSubcycli
WRITES: ustate(interior)
# calculate Y4
READS: pstate(interior)
WRITES: wstate(interior)
SYNC: wstate
READS: Y4(everywhere)
WRITES: wstate(everywhere)
#SYNC: wstate
} "calc Y4"

SCHEDULE TestSubcyclingMC_UpdateU IN TestSubcyclingMC_RK4Group AFTER TestSubcyclingMC_CalcY4
Expand Down
19 changes: 19 additions & 0 deletions TestSubcyclingMC/src/testsubcyclingmc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,21 @@ void CalcYfFromKcs(const Loop::GridDescBaseDevice &grid,
}
}

void CopyWsFromYs(const Loop::GridDescBaseDevice &grid,
// output
const Loop::GF3D2<CCTK_REAL> &u_w,
const Loop::GF3D2<CCTK_REAL> &rho_w,
// input
const Loop::GF3D2<const CCTK_REAL> &u_Y,
const Loop::GF3D2<const CCTK_REAL> &rho_Y) {
grid.loop_ghosts_device<0, 0, 0>(grid.nghostzones,
[=] CCTK_DEVICE(const Loop::PointDesc &p)
CCTK_ATTRIBUTE_ALWAYS_INLINE {
u_w(p.I) = u_Y(p.I);
rho_w(p.I) = rho_Y(p.I);
});
}

extern "C" void TestSubcyclingMC_CalcY1(CCTK_ARGUMENTS) {
DECLARE_CCTK_ARGUMENTSX_TestSubcyclingMC_CalcY1;
grid.loop_int_device<0, 0, 0>(grid.nghostzones,
Expand All @@ -244,6 +259,7 @@ extern "C" void TestSubcyclingMC_CalcY1(CCTK_ARGUMENTS) {
u_w(p.I) = u(p.I);
rho_w(p.I) = rho(p.I);
});
CopyWsFromYs(grid, u_w, rho_w, u_Y1, rho_Y1);
}

extern "C" void TestSubcyclingMC_CalcY2(CCTK_ARGUMENTS) {
Expand All @@ -252,6 +268,7 @@ extern "C" void TestSubcyclingMC_CalcY2(CCTK_ARGUMENTS) {
CCTK_DELTA_TIME / CCTK_REAL(6.)); // k1
CalcYs(grid, u_w, rho_w, u_p, rho_p, u_k1, rho_k1,
CCTK_DELTA_TIME * CCTK_REAL(0.5)); // Y2
CopyWsFromYs(grid, u_w, rho_w, u_Y2, rho_Y2);
}

extern "C" void TestSubcyclingMC_CalcY3(CCTK_ARGUMENTS) {
Expand All @@ -260,6 +277,7 @@ extern "C" void TestSubcyclingMC_CalcY3(CCTK_ARGUMENTS) {
CCTK_DELTA_TIME / CCTK_REAL(3.)); // k2
CalcYs(grid, u_w, rho_w, u_p, rho_p, u_k2, rho_k2,
CCTK_DELTA_TIME * CCTK_REAL(0.5)); // Y3
CopyWsFromYs(grid, u_w, rho_w, u_Y3, rho_Y3);
}

extern "C" void TestSubcyclingMC_CalcY4(CCTK_ARGUMENTS) {
Expand All @@ -268,6 +286,7 @@ extern "C" void TestSubcyclingMC_CalcY4(CCTK_ARGUMENTS) {
CCTK_DELTA_TIME / CCTK_REAL(3.)); // k3
CalcYs(grid, u_w, rho_w, u_p, rho_p, u_k3, rho_k3,
CCTK_DELTA_TIME); // Y4
CopyWsFromYs(grid, u_w, rho_w, u_Y4, rho_Y4);
}

extern "C" void TestSubcyclingMC_UpdateU(CCTK_ARGUMENTS) {
Expand Down

0 comments on commit a6b5a3e

Please sign in to comment.