Skip to content

Commit

Permalink
fix tests and update prim velocity
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahm-LANL committed Dec 6, 2023
1 parent ee84cbd commit b4985be
Show file tree
Hide file tree
Showing 38 changed files with 182 additions and 174 deletions.
18 changes: 9 additions & 9 deletions src/analysis/history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ Real ReduceMassAccretionRate(MeshData<Real> *md) {
const Real xh = pars.Get<Real>("xh");

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

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

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 pvel_lo = imap[p::velocity::name()].first;
const int pvel_hi = imap[p::velocity::name()].second;

auto geom = Geometry::GetCoordinateSystem(md);

Expand Down Expand Up @@ -78,14 +78,14 @@ Real ReduceJetEnergyFlux(MeshData<Real> *md) {
const Real xh = pars.Get<Real>("xh");

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

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

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 pvel_lo = imap[p::velocity::name()].first;
const int pvel_hi = imap[p::velocity::name()].second;
const int pb_lo = imap[p::bfield].first;
const int pb_hi = imap[p::bfield].second;

Expand Down Expand Up @@ -137,14 +137,14 @@ Real ReduceJetMomentumFlux(MeshData<Real> *md) {
const Real xh = pars.Get<Real>("xh");

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

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

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 pvel_lo = imap[p::velocity::name()].first;
const int pvel_hi = imap[p::velocity::name()].second;
const int pb_lo = imap[p::bfield].first;
const int pb_hi = imap[p::bfield].second;

Expand Down
10 changes: 5 additions & 5 deletions src/fixup/fixup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,17 +307,17 @@ TaskStatus ApplyFloorsImpl(T *rc, IndexDomain domain = IndexDomain::entire) {
if (!enable_floors) return TaskStatus::complete;

const std::vector<std::string> vars(
{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});
{p::density::name(), c::density, p::velocity::name(), 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::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;
const int pvel_lo = imap[p::velocity::name()].first;
const int pvel_hi = imap[p::velocity::name()].second;
const int cmom_lo = imap[c::momentum].first;
const int cmom_hi = imap[c::momentum].second;
const int peng = imap[p::energy].first;
Expand Down
6 changes: 3 additions & 3 deletions src/fixup/fixup_c2p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ TaskStatus ConservedToPrimitiveFixupImpl(T *rc) {

const std::vector<std::string> vars({p::density::name(),
c::density,
p::velocity,
p::velocity::name(),
c::momentum,
p::energy,
c::energy,
Expand All @@ -87,8 +87,8 @@ TaskStatus ConservedToPrimitiveFixupImpl(T *rc) {

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;
const int pvel_lo = imap[p::velocity::name()].first;
const int pvel_hi = imap[p::velocity::name()].second;
const int cmom_lo = imap[c::momentum].first;
const int cmom_hi = imap[c::momentum].second;
const int peng = imap[p::energy].first;
Expand Down
6 changes: 3 additions & 3 deletions src/fixup/fixup_radc2p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ TaskStatus RadConservedToPrimitiveFixupImpl(T *rc) {
bool update_rad = rad_pkg->Param<bool>("active");
if (!enable_c2p_fixup || !update_rad) return TaskStatus::complete;

const std::vector<std::string> vars({p::velocity, p::ye, c::ye, pr::J, pr::H, cr::E,
cr::F, ir::tilPi, ir::c2pfail, impl::fail});
const std::vector<std::string> vars({p::velocity::name(), p::ye, c::ye, pr::J, pr::H,
cr::E, cr::F, ir::tilPi, ir::c2pfail, impl::fail});

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

auto idx_pvel = imap.GetFlatIdx(p::velocity);
auto idx_pvel = imap.GetFlatIdx(p::velocity::name());
int pye = imap[p::ye].second; // negative if not present
int cye = imap[c::ye].second;
auto idx_J = imap.GetFlatIdx(pr::J, false);
Expand Down
8 changes: 4 additions & 4 deletions src/fixup/fixup_src.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ TaskStatus SourceFixupImpl(T *rc) {
auto bounds = fix_pkg->Param<Bounds>("bounds");

const std::vector<std::string> vars(
{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, ir::srcfail, ir::tilPi});
{p::density::name(), c::density, p::velocity::name(), 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, ir::srcfail, ir::tilPi});

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

const int prho = imap[p::density::name()].first;
const int crho = imap[c::density].first;
auto idx_pvel = imap.GetFlatIdx(p::velocity);
auto idx_pvel = imap.GetFlatIdx(p::velocity::name());
auto idx_cmom = imap.GetFlatIdx(c::momentum);
const int peng = imap[p::energy].first;
const int ceng = imap[c::energy].first;
Expand Down
7 changes: 4 additions & 3 deletions src/fluid/con2prim.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ class ConToPrim {
ConToPrim(Data_t *rc, PackIndexMap imap, const Real tol, const int max_iterations)
: var(rc->PackVariables(Vars(), imap)),
prho(imap[fluid_prim::density::name()].first),
crho(imap[fluid_cons::density].first), pvel_lo(imap[fluid_prim::velocity].first),
pvel_hi(imap[fluid_prim::velocity].second),
crho(imap[fluid_cons::density].first),
pvel_lo(imap[fluid_prim::velocity::name()].first),
pvel_hi(imap[fluid_prim::velocity::name()].second),
cmom_lo(imap[fluid_cons::momentum].first),
cmom_hi(imap[fluid_cons::momentum].second), peng(imap[fluid_prim::energy].first),
ceng(imap[fluid_cons::energy].first), pb_lo(imap[fluid_prim::bfield].first),
Expand All @@ -149,7 +150,7 @@ class ConToPrim {

std::vector<std::string> Vars() {
return std::vector<std::string>(
{fluid_prim::density::name(), fluid_cons::density, fluid_prim::velocity,
{fluid_prim::density::name(), fluid_cons::density, fluid_prim::velocity::name(),
fluid_cons::momentum, fluid_prim::energy, fluid_cons::energy, fluid_prim::bfield,
fluid_cons::bfield, fluid_prim::ye, fluid_cons::ye, fluid_prim::pressure,
fluid_prim::temperature, internal_variables::cell_signal_speed,
Expand Down
7 changes: 4 additions & 3 deletions src/fluid/con2prim_robust.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ class ConToPrim {
const bool fail_on_ceilings)
: bounds(bnds), var(rc->PackVariables(Vars(), imap)),
prho(imap[fluid_prim::density::name()].first),
crho(imap[fluid_cons::density].first), pvel_lo(imap[fluid_prim::velocity].first),
pvel_hi(imap[fluid_prim::velocity].second),
crho(imap[fluid_cons::density].first),
pvel_lo(imap[fluid_prim::velocity::name()].first),
pvel_hi(imap[fluid_prim::velocity::name()].second),
cmom_lo(imap[fluid_cons::momentum].first),
cmom_hi(imap[fluid_cons::momentum].second), peng(imap[fluid_prim::energy].first),
ceng(imap[fluid_cons::energy].first), pb_lo(imap[fluid_prim::bfield].first),
Expand All @@ -247,7 +248,7 @@ class ConToPrim {

std::vector<std::string> Vars() {
return std::vector<std::string>(
{fluid_prim::density::name(), fluid_cons::density, fluid_prim::velocity,
{fluid_prim::density::name(), fluid_cons::density, fluid_prim::velocity::name(),
fluid_cons::momentum, fluid_prim::energy, fluid_cons::energy, fluid_prim::bfield,
fluid_cons::bfield, fluid_prim::ye, fluid_cons::ye, fluid_prim::pressure,
fluid_prim::temperature, internal_variables::cell_signal_speed,
Expand Down
16 changes: 8 additions & 8 deletions src/fluid/fluid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin) {

// add the primitive variables
physics->template AddField<p::density>(mprim_scalar);
physics->AddField(p::velocity, mprim_threev);
physics->AddField(p::velocity::name(), mprim_threev);
physics->AddField(p::energy, mprim_scalar);
if (mhd) {
physics->AddField(p::bfield, mprim_threev);
Expand Down Expand Up @@ -256,7 +256,7 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin) {

// set up the arrays for left and right states
// add the base state for reconstruction/fluxes
std::vector<std::string> rvars({p::density::name(), p::velocity, p::energy});
std::vector<std::string> rvars({p::density::name(), p::velocity::name(), p::energy});
riemann::FluxState::ReconVars(rvars);
if (mhd) riemann::FluxState::ReconVars(p::bfield);
if (ye) riemann::FluxState::ReconVars(p::ye);
Expand Down Expand Up @@ -349,18 +349,18 @@ TaskStatus PrimitiveToConservedRegion(MeshBlockData<Real> *rc, const IndexRange
namespace impl = internal_variables;
auto *pmb = rc->GetParentPointer();

const std::vector<std::string> vars({p::density::name(), c::density, p::velocity,
c::momentum, p::energy, c::energy, p::bfield,
c::bfield, p::ye, c::ye, p::pressure, p::gamma1,
impl::cell_signal_speed});
const std::vector<std::string> vars({p::density::name(), c::density,
p::velocity::name(), c::momentum, p::energy,
c::energy, p::bfield, c::bfield, p::ye, c::ye,
p::pressure, p::gamma1, impl::cell_signal_speed});

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

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;
const int pvel_lo = imap[p::velocity::name()].first;
const int pvel_hi = imap[p::velocity::name()].second;
const int cmom_lo = imap[c::momentum].first;
const int cmom_hi = imap[c::momentum].second;
const int peng = imap[p::energy].first;
Expand Down
15 changes: 8 additions & 7 deletions src/fluid/riemann.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,14 @@ class FluxState {
bounds(rc->GetParentPointer()->packages.Get("fixup").get()->Param<fixup::Bounds>(
"bounds")),
prho(imap[fluid_prim::density::name()].first),
pvel_lo(imap[fluid_prim::velocity].first), peng(imap[fluid_prim::energy].first),
pb_lo(imap[fluid_prim::bfield].first), pb_hi(imap[fluid_prim::bfield].second),
pye(imap[fluid_prim::ye].second), prs(imap[fluid_prim::pressure].first),
gm1(imap[fluid_prim::gamma1].first), crho(imap[fluid_cons::density].first),
cmom_lo(imap[fluid_cons::momentum].first), ceng(imap[fluid_cons::energy].first),
cb_lo(imap[fluid_cons::bfield].first), cb_hi(imap[fluid_cons::bfield].second),
cye(imap[fluid_cons::ye].first), ncons(5 + (pb_hi - pb_lo + 1) + (cye > 0)) {
pvel_lo(imap[fluid_prim::velocity::name()].first),
peng(imap[fluid_prim::energy].first), pb_lo(imap[fluid_prim::bfield].first),
pb_hi(imap[fluid_prim::bfield].second), pye(imap[fluid_prim::ye].second),
prs(imap[fluid_prim::pressure].first), gm1(imap[fluid_prim::gamma1].first),
crho(imap[fluid_cons::density].first), cmom_lo(imap[fluid_cons::momentum].first),
ceng(imap[fluid_cons::energy].first), cb_lo(imap[fluid_cons::bfield].first),
cb_hi(imap[fluid_cons::bfield].second), cye(imap[fluid_cons::ye].first),
ncons(5 + (pb_hi - pb_lo + 1) + (cye > 0)) {
PARTHENON_REQUIRE_THROWS(
ncons <= NCONS_MAX,
"ncons exceeds NCONS_MAX. Reconfigure to increase NCONS_MAX.");
Expand Down
8 changes: 4 additions & 4 deletions src/fluid/tmunu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

namespace fluid {

const std::vector<std::string> TMUNU_VARS = {fluid_prim::density::name(),
fluid_prim::velocity, fluid_prim::energy,
fluid_prim::pressure, fluid_prim::bfield};
const std::vector<std::string> TMUNU_VARS = {
fluid_prim::density::name(), fluid_prim::velocity::name(), fluid_prim::energy,
fluid_prim::pressure, fluid_prim::bfield};
// Indices are upstairs
template <typename CoordinateSystem, typename Pack>
class StressEnergyTensorCon {
Expand All @@ -47,7 +47,7 @@ class StressEnergyTensorCon {
system_ = Geometry::GetCoordinateSystem(rc);

ir_ = imap[fluid_prim::density::name()].first;
iv_ = imap[fluid_prim::velocity].first;
iv_ = imap[fluid_prim::velocity::name()].first;
iu_ = imap[fluid_prim::energy].first;
ip_ = imap[fluid_prim::pressure].first;
ib_ = imap[fluid_prim::bfield].first;
Expand Down
6 changes: 3 additions & 3 deletions src/pgen/advection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ void ProblemGenerator(MeshBlock *pmb, ParameterInput *pin) {
auto &rc = pmb->meshblock_data.Get();

PackIndexMap imap;
auto v = rc->PackVariables({fluid_prim::density::name(), fluid_prim::velocity,
auto v = rc->PackVariables({fluid_prim::density::name(), fluid_prim::velocity::name(),
fluid_prim::energy, fluid_prim::bfield, fluid_prim::ye,
fluid_prim::pressure, fluid_prim::temperature,
fluid_prim::gamma1},
imap);

const int irho = imap[fluid_prim::density::name()].first;
const int ivlo = imap[fluid_prim::velocity].first;
const int ivhi = imap[fluid_prim::velocity].second;
const int ivlo = imap[fluid_prim::velocity::name()].first;
const int ivhi = imap[fluid_prim::velocity::name()].second;
const int ieng = imap[fluid_prim::energy].first;
const int ib_lo = imap[fluid_prim::bfield].first;
const int ib_hi = imap[fluid_prim::bfield].second;
Expand Down
6 changes: 3 additions & 3 deletions src/pgen/blandford_mckee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ void ProblemGenerator(MeshBlock *pmb, ParameterInput *pin) {
auto &rc = pmb->meshblock_data.Get();

PackIndexMap imap;
auto v = rc->PackVariables({fluid_prim::density::name(), fluid_prim::velocity,
auto v = rc->PackVariables({fluid_prim::density::name(), fluid_prim::velocity::name(),
fluid_prim::energy, fluid_prim::bfield, fluid_prim::ye,
fluid_prim::pressure, fluid_prim::temperature,
fluid_prim::gamma1},
imap);

const int irho = imap[fluid_prim::density::name()].first;
const int ivlo = imap[fluid_prim::velocity].first;
const int ivhi = imap[fluid_prim::velocity].second;
const int ivlo = imap[fluid_prim::velocity::name()].first;
const int ivhi = imap[fluid_prim::velocity::name()].second;
const int ieng = imap[fluid_prim::energy].first;
const int ib_lo = imap[fluid_prim::bfield].first;
const int ib_hi = imap[fluid_prim::bfield].second;
Expand Down
6 changes: 3 additions & 3 deletions src/pgen/bondi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ void ProblemGenerator(MeshBlock *pmb, ParameterInput *pin) {
auto rc = pmb->meshblock_data.Get().get();

PackIndexMap imap;
auto v = rc->PackVariables({fluid_prim::density::name(), fluid_prim::velocity,
auto v = rc->PackVariables({fluid_prim::density::name(), fluid_prim::velocity::name(),
fluid_prim::energy, fluid_prim::bfield, fluid_prim::ye,
fluid_prim::pressure, fluid_prim::temperature,
fluid_prim::gamma1},
imap);

const int irho = imap[fluid_prim::density::name()].first;
const int ivlo = imap[fluid_prim::velocity].first;
const int ivhi = imap[fluid_prim::velocity].second;
const int ivlo = imap[fluid_prim::velocity::name()].first;
const int ivhi = imap[fluid_prim::velocity::name()].second;
const int ieng = imap[fluid_prim::energy].first;
const int ib_lo = imap[fluid_prim::bfield].first;
const int ib_hi = imap[fluid_prim::bfield].second;
Expand Down
4 changes: 2 additions & 2 deletions src/pgen/friedmann.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ void ProblemGenerator(MeshBlock *pmb, ParameterInput *pin) {
auto &rc = pmb->meshblock_data.Get();

PackIndexMap imap;
auto v = rc->PackVariables({fluid_prim::density::name(), fluid_prim::velocity,
auto v = rc->PackVariables({fluid_prim::density::name(), fluid_prim::velocity::name(),
fluid_prim::energy, fluid_prim::bfield, fluid_prim::ye,
fluid_prim::pressure, fluid_prim::temperature,
fluid_prim::gamma1},
imap);
const int irho = imap[fluid_prim::density::name()].first;
const int ivlo = imap[fluid_prim::velocity].first;
const int ivlo = imap[fluid_prim::velocity::name()].first;
const int ieng = imap[fluid_prim::energy].first;
const int iye = imap[fluid_prim::ye].second;
const int iprs = imap[fluid_prim::pressure].first;
Expand Down
4 changes: 2 additions & 2 deletions src/pgen/homogeneous_sphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ void ProblemGenerator(MeshBlock *pmb, ParameterInput *pin) {
auto v = rc->PackVariables(
std::vector<std::string>({radmoment_prim::J, radmoment_prim::H,
fluid_prim::density::name(), fluid_prim::temperature,
fluid_prim::velocity, radmoment_internal::xi,
fluid_prim::velocity::name(), radmoment_internal::xi,
radmoment_internal::phi}),
imap);

auto idJ = imap.GetFlatIdx(radmoment_prim::J);
auto idH = imap.GetFlatIdx(radmoment_prim::H);
auto idv = imap.GetFlatIdx(fluid_prim::velocity);
auto idv = imap.GetFlatIdx(fluid_prim::velocity::name());
auto ixi = imap.GetFlatIdx(radmoment_internal::xi);
auto iphi = imap.GetFlatIdx(radmoment_internal::phi);
const int prho = imap[fluid_prim::density::name()].first;
Expand Down
6 changes: 3 additions & 3 deletions src/pgen/kh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ void ProblemGenerator(MeshBlock *pmb, ParameterInput *pin) {
auto &rc = pmb->meshblock_data.Get();

PackIndexMap imap;
auto v = rc->PackVariables({fluid_prim::density::name(), fluid_prim::velocity,
auto v = rc->PackVariables({fluid_prim::density::name(), fluid_prim::velocity::name(),
fluid_prim::energy, fluid_prim::bfield, fluid_prim::ye,
fluid_prim::pressure, fluid_prim::temperature,
fluid_prim::gamma1},
imap);

const int irho = imap[fluid_prim::density::name()].first;
const int ivlo = imap[fluid_prim::velocity].first;
const int ivhi = imap[fluid_prim::velocity].second;
const int ivlo = imap[fluid_prim::velocity::name()].first;
const int ivhi = imap[fluid_prim::velocity::name()].second;
const int ieng = imap[fluid_prim::energy].first;
const int ib_lo = imap[fluid_prim::bfield].first;
const int ib_hi = imap[fluid_prim::bfield].second;
Expand Down
6 changes: 3 additions & 3 deletions src/pgen/leptoneq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ void ProblemGenerator(MeshBlock *pmb, ParameterInput *pin) {
auto &rc = pmb->meshblock_data.Get();

PackIndexMap imap;
auto v = rc->PackVariables({p::density::name(), p::velocity, p::energy, p::ye,
auto v = rc->PackVariables({p::density::name(), p::velocity::name(), p::energy, p::ye,
p::pressure, p::temperature, p::gamma1},
imap);

const int irho = imap[p::density::name()].first;
const int ivlo = imap[p::velocity].first;
const int ivhi = imap[p::velocity].second;
const int ivlo = imap[p::velocity::name()].first;
const int ivhi = imap[p::velocity::name()].second;
const int ieng = imap[p::energy].first;
const int iye = imap[p::ye].first;
const int iprs = imap[p::pressure].first;
Expand Down
Loading

0 comments on commit b4985be

Please sign in to comment.