Skip to content

Commit

Permalink
moved density to new parthen variables machinery. updated parthenon a…
Browse files Browse the repository at this point in the history
…nd changed all the references to GetParentPointer that I needed to.
  • Loading branch information
jonahm-LANL committed Dec 5, 2023
1 parent ce9b81b commit ee84cbd
Show file tree
Hide file tree
Showing 54 changed files with 428 additions and 386 deletions.
2 changes: 1 addition & 1 deletion external/parthenon
32 changes: 16 additions & 16 deletions src/analysis/history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ Real ReduceMassAccretionRate(MeshData<Real> *md) {
const auto jb = md->GetBoundsJ(IndexDomain::interior);
const auto kb = md->GetBoundsK(IndexDomain::interior);

auto pmb = md->GetParentPointer();
auto &pars = pmb->packages.Get("geometry")->AllParams();
Mesh *pmesh = md->GetMeshPointer();
auto &pars = pmesh->packages.Get("geometry")->AllParams();
const Real xh = pars.Get<Real>("xh");

namespace p = fluid_prim;
const std::vector<std::string> vars({p::density, p::velocity});
const std::vector<std::string> vars({p::density::name(), p::velocity});

PackIndexMap imap;
auto pack = md->PackVariables(vars, imap);

const int prho = imap[p::density].first;
const int prho = imap[p::density::name()].first;
const int pvel_lo = imap[p::velocity].first;
const int pvel_hi = imap[p::velocity].second;

Expand Down Expand Up @@ -73,25 +73,25 @@ Real ReduceJetEnergyFlux(MeshData<Real> *md) {
const auto jb = md->GetBoundsJ(IndexDomain::interior);
const auto kb = md->GetBoundsK(IndexDomain::interior);

auto pmb = md->GetParentPointer();
auto &pars = pmb->packages.Get("geometry")->AllParams();
Mesh *pmesh = md->GetMeshPointer();
auto &pars = pmesh->packages.Get("geometry")->AllParams();
const Real xh = pars.Get<Real>("xh");

namespace p = fluid_prim;
const std::vector<std::string> vars({p::density, p::bfield, p::velocity});
const std::vector<std::string> vars({p::density::name(), p::bfield, p::velocity});

PackIndexMap imap;
auto pack = md->PackVariables(vars, imap);

const int prho = imap[p::density].first;
const int prho = imap[p::density::name()].first;
const int pvel_lo = imap[p::velocity].first;
const int pvel_hi = imap[p::velocity].second;
const int pb_lo = imap[p::bfield].first;
const int pb_hi = imap[p::bfield].second;

auto geom = Geometry::GetCoordinateSystem(md);

const Real sigma_cutoff = pmb->packages.Get("fluid")->Param<Real>("sigma_cutoff");
const Real sigma_cutoff = pmesh->packages.Get("fluid")->Param<Real>("sigma_cutoff");

Real result = 0.0;
parthenon::par_reduce(
Expand Down Expand Up @@ -132,25 +132,25 @@ Real ReduceJetMomentumFlux(MeshData<Real> *md) {
const auto jb = md->GetBoundsJ(IndexDomain::interior);
const auto kb = md->GetBoundsK(IndexDomain::interior);

auto pmb = md->GetParentPointer();
auto &pars = pmb->packages.Get("geometry")->AllParams();
Mesh *pmesh = md->GetMeshPointer();
auto &pars = pmesh->packages.Get("geometry")->AllParams();
const Real xh = pars.Get<Real>("xh");

namespace p = fluid_prim;
const std::vector<std::string> vars({p::density, p::bfield, p::velocity});
const std::vector<std::string> vars({p::density::name(), p::bfield, p::velocity});

PackIndexMap imap;
auto pack = md->PackVariables(vars, imap);

const int prho = imap[p::density].first;
const int prho = imap[p::density::name()].first;
const int pvel_lo = imap[p::velocity].first;
const int pvel_hi = imap[p::velocity].second;
const int pb_lo = imap[p::bfield].first;
const int pb_hi = imap[p::bfield].second;

auto geom = Geometry::GetCoordinateSystem(md);

const Real sigma_cutoff = pmb->packages.Get("fluid")->Param<Real>("sigma_cutoff");
const Real sigma_cutoff = pmesh->packages.Get("fluid")->Param<Real>("sigma_cutoff");

Real result = 0.0;
parthenon::par_reduce(
Expand Down Expand Up @@ -191,8 +191,8 @@ Real ReduceMagneticFluxPhi(MeshData<Real> *md) {
const auto jb = md->GetBoundsJ(IndexDomain::interior);
const auto kb = md->GetBoundsK(IndexDomain::interior);

auto pmb = md->GetParentPointer();
auto &pars = pmb->packages.Get("geometry")->AllParams();
Mesh *pmesh = md->GetMeshPointer();
auto &pars = pmesh->packages.Get("geometry")->AllParams();
const Real xh = pars.Get<Real>("xh");

namespace c = fluid_cons;
Expand Down
36 changes: 18 additions & 18 deletions src/fixup/fixup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,15 @@ TaskStatus ApplyFloorsImpl(T *rc, IndexDomain domain = IndexDomain::entire) {
namespace cr = radmoment_cons;
namespace ir = radmoment_internal;
namespace impl = internal_variables;
auto *pmb = rc->GetParentPointer().get();
IndexRange ib = pmb->cellbounds.GetBoundsI(domain);
IndexRange jb = pmb->cellbounds.GetBoundsJ(domain);
IndexRange kb = pmb->cellbounds.GetBoundsK(domain);
auto *pmesh = rc->GetMeshPointer();
IndexRange ib = rc->GetBoundsI(domain);
IndexRange jb = rc->GetBoundsJ(domain);
IndexRange kb = rc->GetBoundsK(domain);

StateDescriptor *fix_pkg = pmb->packages.Get("fixup").get();
StateDescriptor *eos_pkg = pmb->packages.Get("eos").get();
StateDescriptor *fluid_pkg = pmb->packages.Get("fluid").get();
StateDescriptor *rad_pkg = pmb->packages.Get("radiation").get();
StateDescriptor *fix_pkg = pmesh->packages.Get("fixup").get();
StateDescriptor *eos_pkg = pmesh->packages.Get("eos").get();
StateDescriptor *fluid_pkg = pmesh->packages.Get("fluid").get();
StateDescriptor *rad_pkg = pmesh->packages.Get("radiation").get();

bool rad_active = rad_pkg->Param<bool>("active");

Expand All @@ -307,14 +307,14 @@ TaskStatus ApplyFloorsImpl(T *rc, IndexDomain domain = IndexDomain::entire) {
if (!enable_floors) return TaskStatus::complete;

const std::vector<std::string> vars(
{p::density, c::density, p::velocity, c::momentum, p::energy, c::energy, p::bfield,
p::ye, c::ye, p::pressure, p::temperature, p::gamma1, pr::J, pr::H, cr::E, cr::F,
impl::cell_signal_speed, impl::fail, ir::tilPi});
{p::density::name(), c::density, p::velocity, c::momentum, p::energy, c::energy,
p::bfield, p::ye, c::ye, p::pressure, p::temperature, p::gamma1, pr::J, pr::H,
cr::E, cr::F, impl::cell_signal_speed, impl::fail, ir::tilPi});

PackIndexMap imap;
auto v = rc->PackVariables(vars, imap);

const int prho = imap[p::density].first;
const int prho = imap[p::density::name()].first;
const int crho = imap[c::density].first;
const int pvel_lo = imap[p::velocity].first;
const int pvel_hi = imap[p::velocity].second;
Expand Down Expand Up @@ -352,7 +352,7 @@ TaskStatus ApplyFloorsImpl(T *rc, IndexDomain domain = IndexDomain::entire) {
c2p_floor_scale_fac, c2p_fail_on_floors,
c2p_fail_on_ceilings);

Coordinates_t coords = rc->GetParentPointer().get()->coords;
Coordinates_t coords = rc->GetParentPointer()->coords;

parthenon::par_for(
DEFAULT_LOOP_PATTERN, "ApplyFloors", DevExecSpace(), 0, v.GetDim(5) - 1, kb.s, kb.e,
Expand Down Expand Up @@ -673,7 +673,7 @@ TaskStatus ApplyFloorsImpl(T *rc, IndexDomain domain = IndexDomain::entire) {

template <typename T>
TaskStatus ApplyFloors(T *rc) {
auto *pm = rc->GetParentPointer().get();
auto *pm = rc->GetMeshPointer();
StateDescriptor *rad_pkg = pm->packages.Get("radiation").get();
StateDescriptor *fix_pkg = pm->packages.Get("fixup").get();
const bool enable_rad_floors = fix_pkg->Param<bool>("enable_rad_floors");
Expand Down Expand Up @@ -706,7 +706,7 @@ template TaskStatus ApplyFloors<MeshBlockData<Real>>(MeshBlockData<Real> *rc);
TaskStatus FixFluxes(MeshBlockData<Real> *rc) {
using parthenon::BoundaryFace;
using parthenon::BoundaryFlag;
auto *pmb = rc->GetParentPointer().get();
auto *pmb = rc->GetParentPointer();
auto &fixup_pkg = pmb->packages.Get("fixup");
if (!fixup_pkg->Param<bool>("enable_flux_fixup")) return TaskStatus::complete;

Expand All @@ -723,9 +723,9 @@ TaskStatus FixFluxes(MeshBlockData<Real> *rc) {
}
auto moments_active = rad->Param<bool>("moments_active");

IndexRange ib = pmb->cellbounds.GetBoundsI(IndexDomain::interior);
IndexRange jb = pmb->cellbounds.GetBoundsJ(IndexDomain::interior);
IndexRange kb = pmb->cellbounds.GetBoundsK(IndexDomain::interior);
IndexRange ib = rc->GetBoundsI(IndexDomain::interior);
IndexRange jb = rc->GetBoundsJ(IndexDomain::interior);
IndexRange kb = rc->GetBoundsK(IndexDomain::interior);

const int ndim = pmb->pmy_mesh->ndim;
namespace p = fluid_prim;
Expand Down
36 changes: 18 additions & 18 deletions src/fixup/fixup_c2p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ TaskStatus ConservedToPrimitiveFixupImpl(T *rc) {
namespace ir = radmoment_internal;
namespace pr = radmoment_prim;
namespace cr = radmoment_cons;
auto *pmb = rc->GetParentPointer().get();
IndexRange ib = pmb->cellbounds.GetBoundsI(IndexDomain::interior);
IndexRange jb = pmb->cellbounds.GetBoundsJ(IndexDomain::interior);
IndexRange kb = pmb->cellbounds.GetBoundsK(IndexDomain::interior);
Mesh *pmesh = rc->GetMeshPointer();
IndexRange ib = rc->GetBoundsI(IndexDomain::interior);
IndexRange jb = rc->GetBoundsJ(IndexDomain::interior);
IndexRange kb = rc->GetBoundsK(IndexDomain::interior);

StateDescriptor *fix_pkg = pmb->packages.Get("fixup").get();
StateDescriptor *fluid_pkg = pmb->packages.Get("fluid").get();
StateDescriptor *rad_pkg = pmb->packages.Get("radiation").get();
StateDescriptor *eos_pkg = pmb->packages.Get("eos").get();
StateDescriptor *fix_pkg = pmesh->packages.Get("fixup").get();
StateDescriptor *fluid_pkg = pmesh->packages.Get("fluid").get();
StateDescriptor *rad_pkg = pmesh->packages.Get("radiation").get();
StateDescriptor *eos_pkg = pmesh->packages.Get("eos").get();

const std::vector<std::string> vars({p::density,
const std::vector<std::string> vars({p::density::name(),
c::density,
p::velocity,
c::momentum,
Expand All @@ -85,7 +85,7 @@ TaskStatus ConservedToPrimitiveFixupImpl(T *rc) {
PackIndexMap imap;
auto v = rc->PackVariables(vars, imap);

const int prho = imap[p::density].first;
const int prho = imap[p::density::name()].first;
const int crho = imap[c::density].first;
const int pvel_lo = imap[p::velocity].first;
const int pvel_hi = imap[p::velocity].second;
Expand Down Expand Up @@ -134,9 +134,9 @@ TaskStatus ConservedToPrimitiveFixupImpl(T *rc) {
},
Kokkos::Sum<int>(nfail_total));
printf("total nfail: %i\n", nfail_total);
IndexRange ibi = pmb->cellbounds.GetBoundsI(IndexDomain::interior);
IndexRange jbi = pmb->cellbounds.GetBoundsJ(IndexDomain::interior);
IndexRange kbi = pmb->cellbounds.GetBoundsK(IndexDomain::interior);
IndexRange ibi = rc->GetBoundsI(IndexDomain::interior);
IndexRange jbi = rc->GetBoundsJ(IndexDomain::interior);
IndexRange kbi = rc->GetBoundsK(IndexDomain::interior);
nfail_total = 0;
parthenon::par_reduce(
parthenon::loop_pattern_mdrange_tag, "Rad ConToPrim::Solve fixup failures",
Expand All @@ -150,13 +150,13 @@ TaskStatus ConservedToPrimitiveFixupImpl(T *rc) {
printf("total interior nfail: %i\n", nfail_total);
}

const int ndim = pmb->pmy_mesh->ndim;
const int ndim = pmesh->ndim;

auto eos = eos_pkg->Param<Microphysics::EOS::EOS>("d.EOS");
auto geom = Geometry::GetCoordinateSystem(rc);
auto bounds = fix_pkg->Param<Bounds>("bounds");

Coordinates_t coords = rc->GetParentPointer().get()->coords;
Coordinates_t coords = rc->GetParentPointer()->coords;

auto fluid_c2p_failure_strategy =
fix_pkg->Param<FAILURE_STRATEGY>("fluid_c2p_failure_strategy");
Expand Down Expand Up @@ -356,9 +356,9 @@ TaskStatus ConservedToPrimitiveFixupImpl(T *rc) {

template <typename T>
TaskStatus ConservedToPrimitiveFixup(T *rc) {
auto *pm = rc->GetParentPointer().get();
StateDescriptor *rad_pkg = pm->packages.Get("radiation").get();
StateDescriptor *fix_pkg = pm->packages.Get("fixup").get();
Mesh *pmesh = rc->GetMeshPointer();
StateDescriptor *rad_pkg = pmesh->packages.Get("radiation").get();
StateDescriptor *fix_pkg = pmesh->packages.Get("fixup").get();
const bool enable_rad_floors = fix_pkg->Param<bool>("enable_rad_floors");
std::string method;
if (enable_rad_floors) {
Expand Down
10 changes: 5 additions & 5 deletions src/fixup/fixup_netfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace fixup {

TaskStatus SumMdotPhiForNetFieldScaling(MeshData<Real> *md, const Real t, const int stage,
std::vector<Real> *sums) {
auto *pm = md->GetParentPointer();
Mesh *pm = md->GetMeshPointer();
StateDescriptor *fix_pkg = pm->packages.Get("fixup").get();

const bool enable_phi_enforcement = fix_pkg->Param<bool>("enable_phi_enforcement");
Expand All @@ -64,7 +64,7 @@ TaskStatus SumMdotPhiForNetFieldScaling(MeshData<Real> *md, const Real t, const

TaskStatus NetFieldStartReduce(MeshData<Real> *md, const Real t, const int stage,
AllReduce<std::vector<Real>> *net_field_totals) {
auto *pm = md->GetParentPointer();
Mesh *pm = md->GetMeshPointer();
StateDescriptor *fix_pkg = pm->packages.Get("fixup").get();

const bool enable_phi_enforcement = fix_pkg->Param<bool>("enable_phi_enforcement");
Expand All @@ -88,7 +88,7 @@ TaskStatus NetFieldCheckReduce(MeshData<Real> *md, const Real t, const int stage
return TaskStatus::complete;
}

auto *pm = md->GetParentPointer();
Mesh *pm = md->GetMeshPointer();
StateDescriptor *fix_pkg = pm->packages.Get("fixup").get();

const bool enable_phi_enforcement = fix_pkg->Param<bool>("enable_phi_enforcement");
Expand All @@ -112,7 +112,7 @@ TaskStatus UpdateNetFieldScaleControls(MeshData<Real> *md, const Real t, const R
if (stage != 1) {
return TaskStatus::complete;
}
auto *pm = md->GetParentPointer();
Mesh *pm = md->GetMeshPointer();
StateDescriptor *fix_pkg = pm->packages.Get("fixup").get();

const bool enable_phi_enforcement = fix_pkg->Param<bool>("enable_phi_enforcement");
Expand Down Expand Up @@ -158,7 +158,7 @@ TaskStatus ModifyNetField(MeshData<Real> *md, const Real t, const Real dt,
if (stage != 1 && fiducial) {
return TaskStatus::complete;
}
auto *pm = md->GetParentPointer();
Mesh *pm = md->GetMeshPointer();
StateDescriptor *fix_pkg = pm->packages.Get("fixup").get();

const bool enable_phi_enforcement = fix_pkg->Param<bool>("enable_phi_enforcement");
Expand Down
30 changes: 15 additions & 15 deletions src/fixup/fixup_radc2p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ TaskStatus RadConservedToPrimitiveFixupImpl(T *rc) {
namespace pr = radmoment_prim;
namespace cr = radmoment_cons;

auto *pmb = rc->GetParentPointer().get();
IndexRange ib = pmb->cellbounds.GetBoundsI(IndexDomain::interior);
IndexRange jb = pmb->cellbounds.GetBoundsJ(IndexDomain::interior);
IndexRange kb = pmb->cellbounds.GetBoundsK(IndexDomain::interior);
Mesh *pmesh = rc->GetMeshPointer();
IndexRange ib = rc->GetBoundsI(IndexDomain::interior);
IndexRange jb = rc->GetBoundsJ(IndexDomain::interior);
IndexRange kb = rc->GetBoundsK(IndexDomain::interior);

StateDescriptor *fix_pkg = pmb->packages.Get("fixup").get();
StateDescriptor *eos_pkg = pmb->packages.Get("eos").get();
StateDescriptor *rad_pkg = pmb->packages.Get("radiation").get();
StateDescriptor *fix_pkg = pmesh->packages.Get("fixup").get();
StateDescriptor *eos_pkg = pmesh->packages.Get("eos").get();
StateDescriptor *rad_pkg = pmesh->packages.Get("radiation").get();

bool enable_c2p_fixup = fix_pkg->Param<bool>("enable_c2p_fixup");
bool update_rad = rad_pkg->Param<bool>("active");
Expand Down Expand Up @@ -93,9 +93,9 @@ TaskStatus RadConservedToPrimitiveFixupImpl(T *rc) {
},
Kokkos::Sum<int>(nfail_total));
printf("total rad nfail: %i\n", nfail_total);
IndexRange ibi = pmb->cellbounds.GetBoundsI(IndexDomain::interior);
IndexRange jbi = pmb->cellbounds.GetBoundsJ(IndexDomain::interior);
IndexRange kbi = pmb->cellbounds.GetBoundsK(IndexDomain::interior);
IndexRange ibi = rc->GetBoundsI(IndexDomain::interior);
IndexRange jbi = rc->GetBoundsJ(IndexDomain::interior);
IndexRange kbi = rc->GetBoundsK(IndexDomain::interior);
nfail_total = 0;
parthenon::par_reduce(
parthenon::loop_pattern_mdrange_tag, "Rad ConToPrim::Solve fixup failures",
Expand All @@ -112,10 +112,10 @@ TaskStatus RadConservedToPrimitiveFixupImpl(T *rc) {
auto geom = Geometry::GetCoordinateSystem(rc);
auto bounds = fix_pkg->Param<Bounds>("bounds");

Coordinates_t coords = rc->GetParentPointer().get()->coords;
Coordinates_t coords = rc->GetParentPointer()->coords;

const int nspec = idx_E.DimSize(1);
const int ndim = pmb->pmy_mesh->ndim;
const int ndim = pmesh->ndim;

auto rad_c2p_failure_strategy =
fix_pkg->Param<FAILURE_STRATEGY>("rad_c2p_failure_strategy");
Expand Down Expand Up @@ -223,9 +223,9 @@ TaskStatus RadConservedToPrimitiveFixupImpl(T *rc) {

template <typename T>
TaskStatus RadConservedToPrimitiveFixup(T *rc) {
auto *pm = rc->GetParentPointer().get();
StateDescriptor *rad_pkg = pm->packages.Get("radiation").get();
StateDescriptor *fix_pkg = pm->packages.Get("fixup").get();
Mesh *pmesh = rc->GetMeshPointer();
StateDescriptor *rad_pkg = pmesh->packages.Get("radiation").get();
StateDescriptor *fix_pkg = pmesh->packages.Get("fixup").get();
const bool enable_rad_floors = fix_pkg->Param<bool>("enable_rad_floors");
std::string method;
if (enable_rad_floors) {
Expand Down
Loading

0 comments on commit ee84cbd

Please sign in to comment.