diff --git a/src/phoebus_driver.cpp b/src/phoebus_driver.cpp index 38ceb8f3d..9008c61e8 100644 --- a/src/phoebus_driver.cpp +++ b/src/phoebus_driver.cpp @@ -698,11 +698,12 @@ TaskListStatus PhoebusDriver::RadiationPostStep() { if (do_lightbulb) { pdo_gain_reducer = rad->MutableParam>("do_gain_reducer"); } - TaskRegion &async_region = tc.AddRegion(num_independent_task_lists); - for (int ib = 0; ib < num_independent_task_lists; ib++) { - auto pmb = blocks[ib].get(); - auto &tl = async_region[ib]; - auto &sc0 = pmb->meshblock_data.Get(stage_name[integrator->nstages]); + // creating a new sync region for light bulb functions + const int num_partitions = pmesh->DefaultNumPartitions(); + TaskRegion &sync_region_lb = tc.AddRegion(num_partitions); + for (int ib = 0; ib < num_partitions; ++ib) { + auto &sc0 = pmesh->mesh_data.GetOrAdd("base", ib); + auto &tl = sync_region_lb[ib]; auto finish_gain_reducer = none; if (do_lightbulb) { auto calc_tau = tl.AddTask(none, radiation::LightBulbCalcTau, sc0.get()); @@ -717,9 +718,8 @@ TaskListStatus PhoebusDriver::RadiationPostStep() { tl.AddTask(start_gain_reducer, &parthenon::AllReduce::CheckReduce, pdo_gain_reducer); int reg_dep_id = 0; - async_region.AddRegionalDependencies(reg_dep_id++, ib, finish_gain_reducer); + sync_region_lb.AddRegionalDependencies(reg_dep_id++, ib, finish_gain_reducer); } - auto calculate_four_force = tl.AddTask(finish_gain_reducer, radiation::CoolingFunctionCalculateFourForce, sc0.get(), dt); @@ -976,12 +976,12 @@ TaskListStatus PhoebusDriver::MonteCarloStep() { // Finalization calls { - TaskCollection tc; - TaskRegion &async_region1 = tc.AddRegion(num_task_lists_executed_independently); - for (int ib = 0; ib < num_task_lists_executed_independently; ib++) { - auto pmb = blocks[ib].get(); - auto &tl = async_region1[ib]; - auto &sc0 = pmb->meshblock_data.Get(stage_name[integrator->nstages]); + const int num_partitions = pmesh->DefaultNumPartitions(); + TaskRegion &sync_region = tc.AddRegion(num_partitions); + for (int ib = 0; ib < num_partitions; ++ib) { + auto &base = pmesh->mesh_data.GetOrAdd("base", ib); + auto &sc0 = pmesh->mesh_data.GetOrAdd("base", ib); + auto &tl = sync_region[ib]; auto apply_four_force = tl.AddTask(none, radiation::ApplyRadiationFourForce, sc0.get(), dt); } diff --git a/src/phoebus_utils/relativity_utils.hpp b/src/phoebus_utils/relativity_utils.hpp index b73db829b..a5181081a 100644 --- a/src/phoebus_utils/relativity_utils.hpp +++ b/src/phoebus_utils/relativity_utils.hpp @@ -70,14 +70,22 @@ GetLorentzFactor(const Real vcon[Geometry::NDSPACE], * * RETURN - Lorentz factor in normal observer frame */ +template KOKKOS_INLINE_FUNCTION Real GetLorentzFactor(const Real vcon[Geometry::NDSPACE], - const Geometry::CoordSysMeshBlock &system, - CellLocation loc, const int k, const int j, - const int i) { + const CoordinateSystem_t &system, + CellLocation loc, const int b, const int k, + const int j, const int i) { Real gamma[Geometry::NDSPACE][Geometry::NDSPACE]; - system.Metric(loc, k, j, i, gamma); + system.Metric(loc, b, k, j, i, gamma); return GetLorentzFactor(vcon, gamma); } +template +KOKKOS_INLINE_FUNCTION Real GetLorentzFactor(const Real vcon[Geometry::NDSPACE], + const CoordinateSystem_t &system, + CellLocation loc, const int k, const int j, + const int i) { + return GetLorentzFactor(vcon, system, loc, 0, k, j, i); +} /* * Calculate the coordinate frame four-velocity from the normal observer three-velocity @@ -90,20 +98,28 @@ KOKKOS_INLINE_FUNCTION Real GetLorentzFactor(const Real vcon[Geometry::NDSPACE], * PARAM[IN] - i - X1 index of meshblock cell * PARAM[OUT] - u - Coordinate frame contravariant four-velocity */ -KOKKOS_INLINE_FUNCTION void GetFourVelocity(const Real v[3], - const Geometry::CoordSysMeshBlock &system, - CellLocation loc, const int k, const int j, - const int i, Real u[Geometry::NDFULL]) { +template +KOKKOS_INLINE_FUNCTION void +GetFourVelocity(const Real v[3], const CoordinateSystem_t &system, CellLocation loc, + const int b, const int k, const int j, const int i, + Real u[Geometry::NDFULL]) { Real beta[Geometry::NDSPACE]; - Real W = GetLorentzFactor(v, system, loc, k, j, i); - Real alpha = system.Lapse(loc, k, j, i); - system.ContravariantShift(loc, k, j, i, beta); + Real W = GetLorentzFactor(v, system, loc, b, k, j, i); + Real alpha = system.Lapse(loc, b, k, j, i); + system.ContravariantShift(loc, b, k, j, i, beta); u[0] = robust::ratio(W, std::abs(alpha)); for (int l = 1; l < Geometry::NDFULL; ++l) { u[l] = v[l - 1] - u[0] * beta[l - 1]; } } +template +KOKKOS_INLINE_FUNCTION void +GetFourVelocity(const Real v[3], const CoordinateSystem_t &system, CellLocation loc, + const int k, const int j, const int i, Real u[Geometry::NDFULL]) { + GetFourVelocity(v, system, loc, 0, k, j, i, u); +} + /* * Compute square of magnetic field from primitive velocity and magnetic field * diff --git a/src/radiation/cooling_function.cpp b/src/radiation/cooling_function.cpp index 2762eaf33..b6171ec6b 100644 --- a/src/radiation/cooling_function.cpp +++ b/src/radiation/cooling_function.cpp @@ -16,36 +16,42 @@ #include "phoebus_utils/variables.hpp" #include "radiation.hpp" #include +#include namespace radiation { using Microphysics::Opacities; using Microphysics::RadiationType; -TaskStatus LightBulbCalcTau(MeshBlockData *rc) { +TaskStatus LightBulbCalcTau(MeshData *rc) { namespace p = fluid_prim; namespace c = fluid_cons; namespace iv = internal_variables; + using parthenon::MakePackDescriptor; Mesh *pmesh = rc->GetMeshPointer(); + auto &resolved_pkgs = pmesh->resolved_packages; + const int ndim = pmesh->ndim; - std::vector vars({p::density::name(), iv::tau::name()}); + static auto desc = MakePackDescriptor(resolved_pkgs.get()); PackIndexMap imap; - auto v = rc->PackVariables(vars, imap); - const int prho = imap[p::density::name()].first; - const int ptau = imap[iv::tau::name()].first; + auto v = desc.GetPack(rc); IndexRange ib = rc->GetBoundsI(IndexDomain::interior); IndexRange jb = rc->GetBoundsJ(IndexDomain::interior); IndexRange kb = rc->GetBoundsK(IndexDomain::interior); + const int nblocks = v.GetNBlocks(); + auto &unit_conv = pmesh->packages.Get("phoebus")->Param("unit_conv"); const Real density_conversion_factor = unit_conv.GetMassDensityCodeToCGS(); parthenon::par_for( - DEFAULT_LOOP_PATTERN, "CalcTau", DevExecSpace(), kb.s, kb.e, jb.s, jb.e, ib.s, ib.e, - KOKKOS_LAMBDA(const int k, const int j, const int i) { - const Real rho = v(prho, k, j, i) * density_conversion_factor; // Density in CGS + DEFAULT_LOOP_PATTERN, "CalcTau", DevExecSpace(), 0, nblocks - 1, kb.s, kb.e, jb.s, + jb.e, ib.s, ib.e, + KOKKOS_LAMBDA(const int b, const int k, const int j, const int i) { + const Real rho = + v(b, p::density(), k, j, i) * density_conversion_factor; // Density in CGS const Real lRho = std::log10(rho); // Calculate tau constexpr Real xl1 = LightBulb::HeatAndCool::XL1; @@ -64,25 +70,28 @@ TaskStatus LightBulbCalcTau(MeshBlockData *rc) { } else { tau = std::pow(10, (yl3 - yl2) / (xl3 - xl2) * (lRho - xl2) + yl2); } - v(ptau, k, j, i) = tau; + v(b, iv::tau(), k, j, i) = tau; }); return TaskStatus::complete; } -TaskStatus CheckDoGain(MeshBlockData *rc, bool *do_gain_global) { +TaskStatus CheckDoGain(MeshData *rc, bool *do_gain_global) { if (*do_gain_global) { return TaskStatus::complete; } namespace p = fluid_prim; namespace c = fluid_cons; namespace iv = internal_variables; + using parthenon::MakePackDescriptor; Mesh *pmesh = rc->GetMeshPointer(); + auto &resolved_pkgs = pmesh->resolved_packages; + const int ndim = pmesh->ndim; - std::vector vars({iv::tau::name()}); + static auto desc = MakePackDescriptor(resolved_pkgs.get()); PackIndexMap imap; - auto v = rc->PackVariables(vars, imap); - const int ptau = imap[iv::tau::name()].first; + auto v = desc.GetPack(rc); + const int nblocks = v.GetNBlocks(); IndexRange ib = rc->GetBoundsI(IndexDomain::interior); IndexRange jb = rc->GetBoundsJ(IndexDomain::interior); @@ -96,10 +105,10 @@ TaskStatus CheckDoGain(MeshBlockData *rc, bool *do_gain_global) { int do_gain_local = 0; bool do_gain; parthenon::par_reduce( - parthenon::loop_pattern_mdrange_tag, "calc_do_gain", DevExecSpace(), kb.s, kb.e, - jb.s, jb.e, ib.s, ib.e, - KOKKOS_LAMBDA(const int k, const int j, const int i, int &do_gain) { - do_gain = do_gain + (v(ptau, k, j, i) > 1.e2); + parthenon::loop_pattern_mdrange_tag, "calc_do_gain", DevExecSpace(), 0, nblocks - 1, + kb.s, kb.e, jb.s, jb.e, ib.s, ib.e, + KOKKOS_LAMBDA(const int b, const int k, const int j, const int i, int &do_gain) { + do_gain = do_gain + (v(b, iv::tau(), k, j, i) > 1.e2); }, Kokkos::Sum(do_gain_local)); do_gain = do_gain_local; @@ -107,33 +116,22 @@ TaskStatus CheckDoGain(MeshBlockData *rc, bool *do_gain_global) { return TaskStatus::complete; } -TaskStatus CoolingFunctionCalculateFourForce(MeshBlockData *rc, const double dt) { +TaskStatus CoolingFunctionCalculateFourForce(MeshData *rc, const double dt) { namespace p = fluid_prim; namespace c = fluid_cons; namespace iv = internal_variables; auto *pmb = rc->GetParentPointer(); + using parthenon::MakePackDescriptor; + Mesh *pmesh = rc->GetMeshPointer(); + auto &resolved_pkgs = pmesh->resolved_packages; + const int ndim = pmesh->ndim; - std::vector vars({c::density::name(), p::density::name(), - p::velocity::name(), p::temperature::name(), - p::ye::name(), c::energy::name(), iv::Gcov::name(), - iv::GcovHeat::name(), iv::GcovCool::name(), - iv::Gye::name(), iv::tau::name(), p::energy::name()}); - - PackIndexMap imap; - auto v = rc->PackVariables(vars, imap); - const int crho = imap[c::density::name()].first; - const int prho = imap[p::density::name()].first; - const int pvlo = imap[p::velocity::name()].first; - const int pvhi = imap[p::velocity::name()].second; - const int ptemp = imap[p::temperature::name()].first; - const int pye = imap[p::ye::name()].first; - const int penergy = imap[p::energy::name()].first; - const int Gcov_lo = imap[iv::Gcov::name()].first; - const int Gcov_hi = imap[iv::Gcov::name()].second; - const int Gye = imap[iv::Gye::name()].first; - const int ptau = imap[iv::tau::name()].first; - const int GcovHeat = imap[iv::GcovHeat::name()].first; - const int GcovCool = imap[iv::GcovCool::name()].first; + static auto desc = + MakePackDescriptor(resolved_pkgs.get()); + auto v = desc.GetPack(rc); + const int nblocks = v.GetNBlocks(); IndexRange ib = rc->GetBoundsI(IndexDomain::interior); IndexRange jb = rc->GetBoundsJ(IndexDomain::interior); @@ -167,17 +165,17 @@ TaskStatus CoolingFunctionCalculateFourForce(MeshBlockData *rc, const doub const Real time_conversion_factor = unit_conv.GetTimeCGSToCode(); parthenon::par_for( - DEFAULT_LOOP_PATTERN, "CoolingFunctionCalculateFourForce", DevExecSpace(), kb.s, - kb.e, jb.s, jb.e, ib.s, ib.e, KOKKOS_LAMBDA(const int k, const int j, const int i) { + DEFAULT_LOOP_PATTERN, "CoolingFunctionCalculateFourForce", DevExecSpace(), 0, + nblocks - 1, kb.s, kb.e, jb.s, jb.e, ib.s, ib.e, + KOKKOS_LAMBDA(const int b, const int k, const int j, const int i) { // Initialize five-force to zero - for (int mu = Gcov_lo; mu <= Gcov_lo + 3; mu++) { - v(mu, k, j, i) = 0.; + for (int mu = 0; mu <= 3; mu++) { + v(b, iv::Gcov(mu), k, j, i) = 0.; } - v(Gye, k, j, i) = 0.; + v(b, iv::Gye(), k, j, i) = 0.; }); // Light Bulb with Liebendorfer model - auto &coords = pmb->coords; const bool do_liebendorfer = rad->Param("do_liebendorfer"); const bool do_lightbulb = rad->Param("do_lightbulb"); if (do_lightbulb) { @@ -191,17 +189,20 @@ TaskStatus CoolingFunctionCalculateFourForce(MeshBlockData *rc, const doub const bool do_gain = pdo_gain_reducer->val; parthenon::par_for( - DEFAULT_LOOP_PATTERN, "CoolingFunctionCalculateFourForce", DevExecSpace(), kb.s, - kb.e, jb.s, jb.e, ib.s, ib.e, - KOKKOS_LAMBDA(const int k, const int j, const int i) { - const Real r = std::abs(coords.Xc<1>(k, j, i)); // TODO(MG) coord transform game - const Real rho = v(prho, k, j, i) * density_conversion_factor; // Density in CGS - const Real cdensity = v(crho, k, j, i); // conserved density + DEFAULT_LOOP_PATTERN, "CoolingFunctionCalculateFourForce", DevExecSpace(), 0, + nblocks - 1, kb.s, kb.e, jb.s, jb.e, ib.s, ib.e, + KOKKOS_LAMBDA(const int b, const int k, const int j, const int i) { + auto &coords = v.GetCoordinates(b); + const Real r = std::abs(coords.Xc<1>(k, j, i)); + const Real rho = + v(b, p::density(), k, j, i) * density_conversion_factor; // Density in CGS + const Real cdensity = v(b, c::density(), k, j, i); // conserved density Real Gcov[4][4]; - geom.SpacetimeMetric(CellLocation::Cent, k, j, i, Gcov); + geom.SpacetimeMetric(CellLocation::Cent, b, k, j, i, Gcov); Real Ucon[4]; - Real vel[3] = {v(pvlo, k, j, i), v(pvlo + 1, k, j, i), v(pvlo + 2, k, j, i)}; - GetFourVelocity(vel, geom, CellLocation::Cent, k, j, i, Ucon); + Real vel[3] = {v(b, p::velocity(0), k, j, i), v(b, p::velocity(1), k, j, i), + v(b, p::velocity(2), k, j, i)}; + GetFourVelocity(vel, geom, CellLocation::Cent, b, k, j, i, Ucon); Geometry::Tetrads Tetrads(Ucon, Gcov); Real Jye = 0.0; Real J; @@ -218,7 +219,7 @@ TaskStatus CoolingFunctionCalculateFourForce(MeshBlockData *rc, const doub constexpr Real MeVToCGS = 1.16040892301e10; constexpr Real Tnorm = 2.0 * MeVToCGS; - Real Ye = v(pye, k, j, i); + Real Ye = v(b, p::ye(), k, j, i); if (do_liebendorfer) { constexpr Real Ye_beta = 0.27; @@ -248,19 +249,21 @@ TaskStatus CoolingFunctionCalculateFourForce(MeshBlockData *rc, const doub } Real heat; Real cool; - const Real tau = v(ptau, k, j, i); + const Real tau = v(b, iv::tau(), k, j, i); const Real hfac = LightBulb::HeatAndCool::HFAC * lum; const Real cfac = LightBulb::HeatAndCool::CFAC; Real Xa, Xh, Xn, Xp, Abar, Zbar; Real lambda[2]; lambda[0] = Ye; eos_sc.MassFractionsFromDensityTemperature( - rho, v(ptemp, k, j, i) * temperature_conversion_factor, Xa, Xh, Xn, Xp, - Abar, Zbar, lambda); + rho, v(b, p::temperature(), k, j, i) * temperature_conversion_factor, Xa, + Xh, Xn, Xp, Abar, Zbar, lambda); heat = do_gain * (Xn + Xp) * hfac * std::exp(-tau) * pow((rnorm / (r * length_conversion_factor)), 2); cool = (Xn + Xp) * cfac * std::exp(-tau) * - pow((v(ptemp, k, j, i) * temperature_conversion_factor / Tnorm), 6); + pow((v(b, p::temperature(), k, j, i) * temperature_conversion_factor / + Tnorm), + 6); Real CGSToCodeFact = energy_conversion_factor / mass_conversion_factor / time_conversion_factor; @@ -272,13 +275,15 @@ TaskStatus CoolingFunctionCalculateFourForce(MeshBlockData *rc, const doub Real Gcov_tetrad[4] = {J, 0., 0., 0.}; // minus sign included above Real Gcov_coord[4]; Tetrads.TetradToCoordCov(Gcov_tetrad, Gcov_coord); - for (int mu = Gcov_lo; mu <= Gcov_lo + 3; mu++) { + for (int mu = 0; mu <= 3; mu++) { // detg included above - Kokkos::atomic_add(&(v(mu, k, j, i)), -Gcov_coord[mu - Gcov_lo]); + Kokkos::atomic_add(&(v(b, iv::Gcov(mu), k, j, i)), -Gcov_coord[mu]); } - v(GcovHeat, k, j, i) = v(prho, k, j, i) * density_conversion_factor * heat; - v(GcovCool, k, j, i) = v(prho, k, j, i) * density_conversion_factor * cool; - Kokkos::atomic_add(&(v(Gye, k, j, i)), Jye); + v(b, iv::GcovHeat(), k, j, i) = + v(b, p::density(), k, j, i) * density_conversion_factor * heat; + v(b, iv::GcovCool(), k, j, i) = + v(b, p::density(), k, j, i) * density_conversion_factor * cool; + Kokkos::atomic_add(&(v(b, iv::Gye(), k, j, i)), Jye); }); #else PARTHENON_THROW("Lighbulb only supported with HDF5"); @@ -290,32 +295,36 @@ TaskStatus CoolingFunctionCalculateFourForce(MeshBlockData *rc, const doub auto s = species[sidx]; parthenon::par_for( - DEFAULT_LOOP_PATTERN, "CoolingFunctionCalculateFourForce", DevExecSpace(), - kb.s, kb.e, jb.s, jb.e, ib.s, ib.e, - KOKKOS_LAMBDA(const int k, const int j, const int i) { + DEFAULT_LOOP_PATTERN, "CoolingFunctionCalculateFourForce", DevExecSpace(), 0, + nblocks - 1, kb.s, kb.e, jb.s, jb.e, ib.s, ib.e, + KOKKOS_LAMBDA(const int b, const int k, const int j, const int i) { Real Gcov[4][4]; - geom.SpacetimeMetric(CellLocation::Cent, k, j, i, Gcov); + geom.SpacetimeMetric(CellLocation::Cent, b, k, j, i, Gcov); Real Ucon[4]; - Real vel[3] = {v(pvlo, k, j, i), v(pvlo + 1, k, j, i), - v(pvlo + 2, k, j, i)}; - GetFourVelocity(vel, geom, CellLocation::Cent, k, j, i, Ucon); + Real vel[3] = {v(b, p::velocity(0), k, j, i), v(b, p::velocity(1), k, j, i), + v(b, p::velocity(2), k, j, i)}; + GetFourVelocity(vel, geom, CellLocation::Cent, b, k, j, i, Ucon); Geometry::Tetrads Tetrads(Ucon, Gcov); - const Real Ye = v(pye, k, j, i); + const Real Ye = v(b, p::ye(), k, j, i); - double J = d_opacity.Emissivity(v(prho, k, j, i), v(ptemp, k, j, i), Ye, s); - double Jye = mp_code * d_opacity.NumberEmissivity(v(prho, k, j, i), - v(ptemp, k, j, i), Ye, s); + double J = d_opacity.Emissivity(v(b, p::density(), k, j, i), + v(b, p::temperature(), k, j, i), Ye, s); + double Jye = mp_code * d_opacity.NumberEmissivity( + v(b, p::density(), k, j, i), + v(b, p::temperature(), k, j, i), Ye, s); Real Gcov_tetrad[4] = {-J, 0., 0., 0.}; Real Gcov_coord[4]; Tetrads.TetradToCoordCov(Gcov_tetrad, Gcov_coord); - Real detG = geom.DetG(CellLocation::Cent, k, j, i); + Real detG = geom.DetG(CellLocation::Cent, b, k, j, i); - for (int mu = Gcov_lo; mu <= Gcov_lo + 3; mu++) { - Kokkos::atomic_add(&(v(mu, k, j, i)), -detG * Gcov_coord[mu - Gcov_lo]); + for (int mu = 0; mu <= 3; mu++) { + Kokkos::atomic_add(&(v(b, iv::Gcov(mu), k, j, i)), + -detG * Gcov_coord[mu]); } - Kokkos::atomic_add(&(v(Gye, k, j, i)), -LeptonSign(s) * detG * Jye); + Kokkos::atomic_add(&(v(b, iv::Gye(), k, j, i)), + -LeptonSign(s) * detG * Jye); }); } } diff --git a/src/radiation/radiation.cpp b/src/radiation/radiation.cpp index 0303752a6..cb0cb633e 100644 --- a/src/radiation/radiation.cpp +++ b/src/radiation/radiation.cpp @@ -538,37 +538,38 @@ std::shared_ptr Initialize(ParameterInput *pin) { return physics; } -TaskStatus ApplyRadiationFourForce(MeshBlockData *rc, const double dt) { +TaskStatus ApplyRadiationFourForce(MeshData *rc, const double dt) { PARTHENON_REQUIRE(USE_VALENCIA, "Covariant GRMHD formulation not supported!"); - namespace c = fluid_cons; namespace iv = internal_variables; + using parthenon::MakePackDescriptor; + Mesh *pmesh = rc->GetMeshPointer(); + auto &resolved_pkgs = pmesh->resolved_packages; + const int ndim = pmesh->ndim; + + static auto desc = + MakePackDescriptor( + resolved_pkgs.get()); - std::vector vars({c::density::name(), c::energy::name(), - c::momentum::name(), c::ye::name(), iv::Gcov::name(), - iv::Gye::name()}); PackIndexMap imap; - auto v = rc->PackVariables(vars, imap); - const int crho = imap[c::density::name()].first; - const int ceng = imap[c::energy::name()].first; - const int cmom_lo = imap[c::momentum::name()].first; - const int cmom_hi = imap[c::momentum::name()].second; - const int cye = imap[c::ye::name()].first; - const int Gcov_lo = imap[iv::Gcov::name()].first; - const int Gcov_hi = imap[iv::Gcov::name()].second; - const int Gye = imap[iv::Gye::name()].first; + auto v = desc.GetPack(rc); + const int nblocks = v.GetNBlocks(); + IndexRange ib = rc->GetBoundsI(IndexDomain::interior); IndexRange jb = rc->GetBoundsJ(IndexDomain::interior); IndexRange kb = rc->GetBoundsK(IndexDomain::interior); parthenon::par_for( - DEFAULT_LOOP_PATTERN, "ApplyRadiationFourForce", DevExecSpace(), kb.s, kb.e, jb.s, - jb.e, ib.s, ib.e, KOKKOS_LAMBDA(const int k, const int j, const int i) { - v(ceng, k, j, i) -= v(Gcov_lo, k, j, i) * dt; - v(cmom_lo, k, j, i) += v(Gcov_lo + 1, k, j, i) * dt; - v(cmom_lo + 1, k, j, i) += v(Gcov_lo + 2, k, j, i) * dt; - v(cmom_lo + 2, k, j, i) += v(Gcov_lo + 3, k, j, i) * dt; - v(cye, k, j, i) += v(Gye, k, j, i) * dt; + DEFAULT_LOOP_PATTERN, "ApplyRadiationFourForce", DevExecSpace(), 0, nblocks - 1, + kb.s, kb.e, jb.s, jb.e, ib.s, ib.e, + KOKKOS_LAMBDA(const int b, const int k, const int j, const int i) { + v(b, c::energy(), k, j, i) -= v(b, iv::Gcov(0), k, j, i) * dt; + v(b, c::momentum(0), k, j, i) += v(b, iv::Gcov(1), k, j, i) * dt; + v(b, c::momentum(1), k, j, i) += v(b, iv::Gcov(2), k, j, i) * dt; + v(b, c::momentum(2), k, j, i) += v(b, iv::Gcov(3), k, j, i) * dt; + if (v.Contains(b, c::ye())) { + v(b, c::ye(), k, j, i) += v(b, iv::Gye(), k, j, i) * dt; + } }); return TaskStatus::complete; } diff --git a/src/radiation/radiation.hpp b/src/radiation/radiation.hpp index ee2b7365e..b1935d810 100644 --- a/src/radiation/radiation.hpp +++ b/src/radiation/radiation.hpp @@ -91,14 +91,14 @@ typedef Kokkos::Random_XorShift64_Pool<> RNGPool; std::shared_ptr Initialize(ParameterInput *pin); -TaskStatus ApplyRadiationFourForce(MeshBlockData *rc, const Real dt); +TaskStatus ApplyRadiationFourForce(MeshData *rc, const Real dt); Real EstimateTimestepBlock(MeshBlockData *rc); // Cooling function tasks -TaskStatus CoolingFunctionCalculateFourForce(MeshBlockData *rc, const Real dt); -TaskStatus CheckDoGain(MeshBlockData *rc, bool *do_gain_global); -TaskStatus LightBulbCalcTau(MeshBlockData *rc); +TaskStatus CoolingFunctionCalculateFourForce(MeshData *rc, const Real dt); +TaskStatus CheckDoGain(MeshData *rc, bool *do_gain_global); +TaskStatus LightBulbCalcTau(MeshData *rc); // Monte Carlo tasks TaskStatus MonteCarloSourceParticles(MeshBlock *pmb, MeshBlockData *rc,