Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 28 additions & 65 deletions nuX_M1/schedule.ccl
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,11 @@ SCHEDULE nuX_M1_FiducialVelocity IN nuX_M1_InitialGroup
AFTER (nuX_M1_Reset)
{
LANG: C
READS: ADMBaseX::metric(interior)
READS: AsterX::dens(interior)
READS: HydroBaseX::vel(interior)
WRITES: fidu_velx(interior) fidu_vely(interior) fidu_velz(interior)
WRITES: fidu_w_lorentz(interior)
SYNC: fidu_vel
SYNC: fidu_w_lorentz
READS: ADMBaseX::metric(everywhere)
READS: AsterX::dens(everywhere)
READS: HydroBaseX::vel(everywhere)
WRITES: fidu_velx(everywhere) fidu_vely(everywhere) fidu_velz(everywhere)
WRITES: fidu_w_lorentz(everywhere)
} "Compute the fiducial velocity"


Expand Down Expand Up @@ -132,14 +130,12 @@ if (reset_to_equilibrium) {
AFTER nuX_M1_Reset
{
LANG: C
READS: ADMBaseX::metric(interior)
READS: AsterX::dens(interior)
READS: HydroBaseX::vel(interior)
READS: ADMBaseX::metric(everywhere)
READS: AsterX::dens(everywhere)
READS: HydroBaseX::vel(everywhere)

WRITES: fidu_velx(everywhere) fidu_vely(everywhere) fidu_velz(everywhere)
WRITES: fidu_w_lorentz(everywhere)
SYNC: fidu_vel
SYNC: fidu_w_lorentz
} "Compute the fiducial velocity"

# SCHEDULE nuX_M1_SetToEquilibrium AT CCTK_POST_RECOVER_VARIABLES \
Expand Down Expand Up @@ -216,27 +212,14 @@ SCHEDULE nuX_M1_InitFluxesRHS IN nuX_M1_TimeStep
WRITES: nu_flux_x(everywhere) nu_flux_y(everywhere) nu_flux_z(everywhere)
} "Initialize explicit RHSs to zero"

# Ensure conserved vars have valid ghost zones before closure/fluxes
SCHEDULE nuX_M1_SyncConserved IN nuX_M1_TimeStep AFTER nuX_M1_InitFluxesRHS
{
LANG: C
OPTIONS: SINGLEMAP
SYNC: rN
SYNC: rE
SYNC: rF
} "Sync rN/rE/rF into ghost zones prior to closure/flux computations"

SCHEDULE nuX_M1_FiducialVelocity IN nuX_M1_TimeStep
{
LANG: C
READS: ADMBaseX::metric(interior)
READS: AsterX::dens(interior)
READS: HydroBaseX::vel(interior)
WRITES: fidu_velx(interior) fidu_vely(interior) fidu_velz(interior)
WRITES: fidu_w_lorentz(interior)
SYNC: fidu_vel
SYNC: fidu_w_lorentz

READS: ADMBaseX::metric(everywhere)
READS: AsterX::dens(everywhere)
READS: HydroBaseX::vel(everywhere)
WRITES: fidu_velx(everywhere) fidu_vely(everywhere) fidu_velz(everywhere)
WRITES: fidu_w_lorentz(everywhere)
} "Compute the fiducial velocity"

SCHEDULE nuX_M1_CalcClosure IN nuX_M1_TimeStep AFTER nuX_M1_FiducialVelocity
Expand Down Expand Up @@ -278,21 +261,6 @@ else {
} "Compute the opacities"
}

# Sync closure/opacity outputs so 4-pt stencil sees valid ghost data
SCHEDULE nuX_M1_SyncDerived IN nuX_M1_TimeStep \
AFTER (nuX_M1_CalcOpacity nuX_M1_CalcFakeOpacity nuX_M1_CalcClosure)
BEFORE nuX_M1_CalcFluxes
{
LANG: C
OPTIONS: SINGLEMAP
SYNC: rP
SYNC: rJ
SYNC: rHt
SYNC: rH
SYNC: chi
SYNC: opacs
} "Sync closure/opacities into ghost zones before flux divergence"

if (include_fluxes) {

SCHEDULE nuX_M1_CalcFluxes IN nuX_M1_TimeStep \
Expand Down Expand Up @@ -321,7 +289,6 @@ if (include_fluxes) {


WRITES: nu_flux_x(everywhere) nu_flux_y(everywhere) nu_flux_z(everywhere)
SYNC: nu_flux_x nu_flux_y nu_flux_z
} "Compute neutrino transport fluxes at cell centres"

SCHEDULE nuX_M1_UpdateRHSFromFluxes IN nuX_M1_TimeStep \
Expand Down Expand Up @@ -351,7 +318,6 @@ if (include_fluxes) {
READS: rN_rhs(interior) rE_rhs(interior) rF_rhs(interior)
WRITES: rN_rhs(interior) rE_rhs(interior) rF_rhs(interior)

SYNC: rN_rhs rE_rhs rF_rhs
} "Add limited flux divergence to the neutrino RHS"
}

Expand Down Expand Up @@ -396,7 +362,7 @@ SCHEDULE nuX_M1_CalcUpdate IN nuX_M1_TimeStep \
WRITES: AsterX::mom(interior) AsterX::tau(interior) AsterX::DYe(interior)
WRITES: rN(interior) rE(interior) rF(interior)

SYNC: chi rN rE rF fluidsources AsterX::mom AsterX::tau AsterX::DYe
SYNC: rN rE rF AsterX::mom AsterX::tau AsterX::DYe

} "Semi-implicit update of radiation and matter fields"

Expand Down Expand Up @@ -437,14 +403,14 @@ SCHEDULE GROUP nuX_M1_BoundaryConditions IN nuX_M1_TimeStep \
} "Apply boundary conditions during the evolution"
# -----------------------------------------------------------------------------

SCHEDULE nuX_M1_Sync IN nuX_M1_BoundaryConditions
{
LANG: C
OPTIONS: SINGLEMAP
SYNC: rN
SYNC: rE
SYNC: rF
} "Select boundary conditions"
# SCHEDULE nuX_M1_Sync IN nuX_M1_BoundaryConditions
# {
# LANG: C
# OPTIONS: SINGLEMAP
# SYNC: rN
# SYNC: rE
# SYNC: rF
# } "Select boundary conditions"

SCHEDULE GROUP ApplyBCs AS nuX_M1_ApplyBCs IN nuX_M1_BoundaryConditions \
AFTER nuX_M1_Sync
Expand All @@ -459,14 +425,12 @@ if (add_to_Tmunu) {
SCHEDULE nuX_M1_FiducialVelocity IN nuX_M1_Tmunu BEFORE nuX_M1_AddToTmunu
{
LANG: C
READS: ADMBaseX::metric(interior)
READS: AsterX::dens(interior)
READS: HydroBaseX::vel(interior)
READS: nuX_m1_mask(interior)
WRITES: fidu_velx(interior) fidu_vely(interior) fidu_velz(interior)
WRITES: fidu_w_lorentz(interior)
SYNC: fidu_vel
SYNC: fidu_w_lorentz
READS: ADMBaseX::metric(everywhere)
READS: AsterX::dens(everywhere)
READS: HydroBaseX::vel(everywhere)
READS: nuX_m1_mask(everywhere)
WRITES: fidu_velx(everywhere) fidu_vely(everywhere) fidu_velz(everywhere)
WRITES: fidu_w_lorentz(everywhere)
} "Compute the fiducial velocity"

SCHEDULE nuX_M1_AddToTmunu IN nuX_M1_Tmunu
Expand All @@ -478,7 +442,6 @@ if (add_to_Tmunu) {
READS: rE(everywhere) rF(everywhere)
READS: TmunuBaseX::eTtt(everywhere) TmunuBaseX::eTti(everywhere) TmunuBaseX::eTij(everywhere)
WRITES: TmunuBaseX::eTtt(everywhere) TmunuBaseX::eTti(everywhere) TmunuBaseX::eTij(everywhere)
SYNC: TmunuBaseX::eTtt TmunuBaseX::eTti TmunuBaseX::eTij
} "Adds the contribution of radiation to the global stress-energy tensor"
}

Expand Down
1 change: 0 additions & 1 deletion nuX_M1/src/make.code.defn
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ nuX_M1_init_fluxes_rhs.cxx \
nuX_M1_param_check.cxx \
nuX_M1_reset.cxx \
nuX_M1_setmask.cxx \
nuX_M1_sync.cxx \
nuX_M1_time_integrator.cxx \
nuX_M1_tmunu.cxx \
nuX_M1_calc_update.cxx \
Expand Down
18 changes: 13 additions & 5 deletions nuX_M1/src/nuX_M1_calc_fluxes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ CCTK_DEVICE CCTK_HOST void M1_ComputePhysicalFluxes(CCTK_ARGUMENTS) {
CCTK_REAL *restrict nu_flux_dir =
(dir == 0 ? nu_flux_x : (dir == 1 ? nu_flux_y : nu_flux_z));

constexpr vect<int, dim> face_centered = {!(dir == 0), !(dir == 1),
!(dir == 2)};

tensor::slicing_geometry_const geom(layout_vc, layout_cc, alp, betax, betay,
betaz, gxx, gxy, gxz, gyy, gyz, gzz, kxx,
kxy, kxz, kyy, kyz, kzz);
Expand All @@ -89,14 +92,15 @@ CCTK_DEVICE CCTK_HOST void M1_ComputePhysicalFluxes(CCTK_ARGUMENTS) {
const int groupspec = ngroups * nspecies;

//--------------------------------------------------------------------
// GPU loop over all cells (INCLUDING ghost zones)
// GPU loop over all cells (INCLUDING ghost zones) in flux direction,
// interior in other directions.
//
// This matches THC's "1st pass compute the fluxes", which computes
// fluxes over the full 1D line including ghosts so that the subsequent
// RHS update can safely reference fluxes near the interior boundary.
//--------------------------------------------------------------------
grid.loop_all_device<1, 1, 1>(
grid.nghostzones, [=] CCTK_DEVICE(const PointDesc &p) {
grid.loop_mixcc_device<1, 1, 1>(
grid.nghostzones, face_centered, grid.nghostzones[dir], [=] CCTK_DEVICE(const PointDesc &p) {
const int i = p.i;
const int j = p.j;
const int k = p.k;
Expand Down Expand Up @@ -205,15 +209,19 @@ template <int dir> void M1_UpdateRHSFromFluxes(CCTK_ARGUMENTS) {
const CCTK_REAL *nu_flux_dir =
(dir == 0 ? nu_flux_x : (dir == 1 ? nu_flux_y : nu_flux_z));

constexpr vect<int, dim> face_centered = {!(dir == 0), !(dir == 1),
!(dir == 2)};

tensor::slicing_geometry_const geom(layout_vc, layout_cc, alp, betax, betay,
betaz, gxx, gxy, gxz, gyy, gyz, gzz, kxx,
kxy, kxz, kyy, kyz, kzz);

// THC needs at least 2 ghost zones along each direction
assert(cctk_nghostzones[dir] >= 2);

grid.loop_int_device<1, 1, 1>(
grid.nghostzones,
// Loop over interior + 1, as flux gridfunctions are physically face-centered but defined as cell-centered
grid.loop_mixcc_device<1, 1, 1>(
grid.nghostzones, face_centered, 1,
[=] CCTK_DEVICE(const PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE {
const int i = p.i;
const int j = p.j;
Expand Down
6 changes: 3 additions & 3 deletions nuX_M1/src/nuX_M1_fiducial_velocity.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extern "C" void nuX_M1_FiducialVelocity(CCTK_ARGUMENTS) {

if (CCTK_Equals(fiducial_velocity, "fluid")) {

grid.loop_int_device<1, 1, 1>(
grid.loop_all_device<1, 1, 1>(
grid.nghostzones,
[=] CCTK_DEVICE(const PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE {
const int ijk = layout_cc.linear(p.i, p.j, p.k);
Expand Down Expand Up @@ -67,7 +67,7 @@ extern "C" void nuX_M1_FiducialVelocity(CCTK_ARGUMENTS) {

} else if (CCTK_Equals(fiducial_velocity, "mixed")) {

grid.loop_int_device<1, 1, 1>(
grid.loop_all_device<1, 1, 1>(
grid.nghostzones,
[=] CCTK_DEVICE(const PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE {
const int ijk = layout_cc.linear(p.i, p.j, p.k);
Expand Down Expand Up @@ -98,7 +98,7 @@ extern "C" void nuX_M1_FiducialVelocity(CCTK_ARGUMENTS) {

} else {

grid.loop_int_device<1, 1, 1>(
grid.loop_all_device<1, 1, 1>(
grid.nghostzones,
[=] CCTK_DEVICE(const PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE {
const int ijk = layout_cc.linear(p.i, p.j, p.k);
Expand Down
45 changes: 0 additions & 45 deletions nuX_M1/src/nuX_M1_sync.cxx

This file was deleted.