Skip to content

Commit 020c985

Browse files
committed
Use block split
1 parent 28dfd9d commit 020c985

1 file changed

Lines changed: 96 additions & 34 deletions

File tree

src/hydro/hydro.cpp

Lines changed: 96 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,47 +1117,109 @@ TaskStatus CalculateFluxes(MeshData<Real> *u0_data, MeshData<Real> *u1_data,
11171117
11181118
*/
11191119

1120-
ib = u0_data->GetBlockData(0)->GetBoundsI(IndexDomain::interior);
1121-
jb = u0_data->GetBlockData(0)->GetBoundsJ(IndexDomain::interior);
1122-
kb = u0_data->GetBlockData(0)->GetBoundsK(IndexDomain::interior);
1120+
const auto ibf = u0_data->GetBlockData(0)->GetBoundsI(IndexDomain::interior);
1121+
const auto jbf = u0_data->GetBlockData(0)->GetBoundsJ(IndexDomain::interior);
1122+
const auto kbf = u0_data->GetBlockData(0)->GetBoundsK(IndexDomain::interior);
1123+
const auto nih = (ibf.e - ibf.s + 1) / 2;
1124+
const auto njh = (jbf.e - jbf.s + 1) / 2;
1125+
const auto nkh = (kbf.e - kbf.s + 1) / 2;
11231126
// Important, this assumes that dx1=dx2=dx3! (same in Riemann solve where flx is set)
11241127

1125-
if constexpr (recon == Reconstruction::dc) {
1128+
for (int d = 0; d < 8; d++) {
1129+
if (d == 0) {
1130+
ib.s = ibf.s;
1131+
jb.s = jbf.s;
1132+
kb.s = kbf.s;
1133+
ib.e = ibf.s + nih;
1134+
jb.e = jbf.s + njh;
1135+
kb.e = kbf.s + nkh;
1136+
} else if (d == 1) {
1137+
ib.s = ibf.s + nih + 1;
1138+
jb.s = jbf.s;
1139+
kb.s = kbf.s;
1140+
ib.e = ibf.e;
1141+
jb.e = jbf.s + njh;
1142+
kb.e = kbf.s + nkh;
1143+
} else if (d == 2) {
1144+
ib.s = ibf.s;
1145+
jb.s = jbf.s + njh + 1;
1146+
kb.s = kbf.s;
1147+
ib.e = ibf.s + nih;
1148+
jb.e = jbf.e;
1149+
kb.e = kbf.s + nkh;
1150+
} else if (d == 3) {
1151+
ib.s = ibf.s + nih + 1;
1152+
jb.s = jbf.s + njh + 1;
1153+
kb.s = kbf.s;
1154+
ib.e = ibf.e;
1155+
jb.e = jbf.e;
1156+
kb.e = kbf.s + nkh;
1157+
} else if (d == 4) {
1158+
ib.s = ibf.s;
1159+
jb.s = jbf.s;
1160+
kb.s = kbf.s + nkh + 1;
1161+
ib.e = ibf.s + nih;
1162+
jb.e = jbf.s + njh;
1163+
kb.e = kbf.e;
1164+
} else if (d == 5) {
1165+
ib.s = ibf.s + nih + 1;
1166+
jb.s = jbf.s;
1167+
kb.s = kbf.s + nkh + 1;
1168+
ib.e = ibf.e;
1169+
jb.e = jbf.s + njh;
1170+
kb.e = kbf.e;
1171+
} else if (d == 6) {
1172+
ib.s = ibf.s;
1173+
jb.s = jbf.s + njh + 1;
1174+
kb.s = kbf.s + nkh + 1;
1175+
ib.e = ibf.s + nih;
1176+
jb.e = jbf.e;
1177+
kb.e = kbf.e;
1178+
} else if (d == 7) {
1179+
ib.s = ibf.s + nih + 1;
1180+
jb.s = jbf.s + njh + 1;
1181+
kb.s = kbf.s + nkh + 1;
1182+
ib.e = ibf.e;
1183+
jb.e = jbf.e;
1184+
kb.e = kbf.e;
1185+
}
1186+
if constexpr (recon == Reconstruction::dc) {
1187+
pmb->par_for(
1188+
"x1 recon DC", 0, u0_cons_pack.GetDim(5) - 1, 0, u0_cons_pack.GetDim(4) - 1,
1189+
kb.s, kb.e, jb.s, jb.e, ib.s - 1, ib.e + 1,
1190+
KOKKOS_LAMBDA(const int b, const int n, const int k, const int j, const int i) {
1191+
const auto &q = u0_prim_pack(b);
1192+
u0_wl_pack(b, n, k, j, i + 1) = u0_wr_pack(b, n, k, j, i) = q(n, k, j, i);
1193+
});
1194+
} else {
1195+
pmb->par_for(
1196+
"x1 recon PPM", 0, u0_cons_pack.GetDim(5) - 1, 0, u0_cons_pack.GetDim(4) - 1,
1197+
kb.s, kb.e, jb.s, jb.e, ib.s - 1, ib.e + 1,
1198+
KOKKOS_LAMBDA(const int b, const int n, const int k, const int j, const int i) {
1199+
const auto &q = u0_prim_pack(b);
1200+
PPM(q(n, k, j, i - 2), q(n, k, j, i - 1), q(n, k, j, i), q(n, k, j, i + 1),
1201+
q(n, k, j, i + 2), u0_wl_pack(b, n, k, j, i + 1),
1202+
u0_wr_pack(b, n, k, j, i));
1203+
});
1204+
}
11261205
pmb->par_for(
1127-
"x1 recon DC", 0, u0_cons_pack.GetDim(5) - 1, 0, u0_cons_pack.GetDim(4) - 1, kb.s,
1128-
kb.e, jb.s, jb.e, ib.s - 1, ib.e + 1,
1129-
KOKKOS_LAMBDA(const int b, const int n, const int k, const int j, const int i) {
1130-
const auto &q = u0_prim_pack(b);
1131-
u0_wl_pack(b, n, k, j, i + 1) = u0_wr_pack(b, n, k, j, i) = q(n, k, j, i);
1206+
"x1 Riemann", 0, u0_cons_pack.GetDim(5) - 1, kb.s, kb.e, jb.s, jb.e, ib.s,
1207+
ib.e + 1, KOKKOS_LAMBDA(const int b, const int k, const int j, const int i) {
1208+
auto &wl = u0_wl_pack(b);
1209+
const auto &wr = u0_wr_pack(b);
1210+
riemann.Solve(k, j, i, IV1, wl, wr, eos, c_h);
11321211
});
1133-
} else {
11341212
pmb->par_for(
1135-
"x1 recon PPM", 0, u0_cons_pack.GetDim(5) - 1, 0, u0_cons_pack.GetDim(4) - 1,
1136-
kb.s, kb.e, jb.s, jb.e, ib.s - 1, ib.e + 1,
1137-
KOKKOS_LAMBDA(const int b, const int n, const int k, const int j, const int i) {
1138-
const auto &q = u0_prim_pack(b);
1139-
PPM(q(n, k, j, i - 2), q(n, k, j, i - 1), q(n, k, j, i), q(n, k, j, i + 1),
1140-
q(n, k, j, i + 2), u0_wl_pack(b, n, k, j, i + 1),
1141-
u0_wr_pack(b, n, k, j, i));
1213+
"UpdateFluxDiv x1", 0, u0_cons_pack.GetDim(5) - 1, 0, u0_cons_pack.GetDim(4) - 1,
1214+
kb.s, kb.e, jb.s, jb.e, ib.s, ib.e,
1215+
KOKKOS_LAMBDA(const int b, const int v, const int k, const int j, const int i) {
1216+
auto &wl = u0_wl_pack(b);
1217+
// WARNING: removing gam0 is specific to the VL2 integrator
1218+
u0_cons_pack(b, v, k, j, i) = // gam0 * u0_cons_pack(b, v, k, j, i) +
1219+
gam1 * u1_cons_pack(b, v, k, j, i) -
1220+
beta_dt * (wl(v, k, j, i + 1) - wl(v, k, j, i)) / dx1;
11421221
});
11431222
}
1144-
pmb->par_for(
1145-
"x1 Riemann", 0, u0_cons_pack.GetDim(5) - 1, kb.s, kb.e, jb.s, jb.e, ib.s, ib.e + 1,
1146-
KOKKOS_LAMBDA(const int b, const int k, const int j, const int i) {
1147-
auto &wl = u0_wl_pack(b);
1148-
const auto &wr = u0_wr_pack(b);
1149-
riemann.Solve(k, j, i, IV1, wl, wr, eos, c_h);
1150-
});
1151-
pmb->par_for(
1152-
"UpdateFluxDiv x1", 0, u0_cons_pack.GetDim(5) - 1, 0, u0_cons_pack.GetDim(4) - 1,
1153-
kb.s, kb.e, jb.s, jb.e, ib.s, ib.e,
1154-
KOKKOS_LAMBDA(const int b, const int v, const int k, const int j, const int i) {
1155-
auto &wl = u0_wl_pack(b);
1156-
// WARNING: removing gam0 is specific to the VL2 integrator
1157-
u0_cons_pack(b, v, k, j, i) = // gam0 * u0_cons_pack(b, v, k, j, i) +
1158-
gam1 * u1_cons_pack(b, v, k, j, i) -
1159-
beta_dt * (wl(v, k, j, i + 1) - wl(v, k, j, i)) / dx1;
1160-
});
11611223
//--------------------------------------------------------------------------------------
11621224
// j-direction
11631225
if (pmb->pmy_mesh->ndim >= 2) {

0 commit comments

Comments
 (0)