Skip to content
Merged
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
20 changes: 11 additions & 9 deletions src/gas/gas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin,
const Real cfl_number = pin->GetOrAddReal("gas", "cfl", 0.8);
params.Add("cfl", cfl_number);

// Floors
const Real dfloor = pin->GetOrAddReal("gas", "dfloor", 1.0e-20);
const Real siefloor = pin->GetOrAddReal("gas", "siefloor", 1.0e-20);
params.Add("dfloor", dfloor);
params.Add("siefloor", siefloor);

// Equation of state
std::string eos_type = "none";
if (pin->DoesBlockExist("gas/eos/ideal") || (pin->DoesParameterExist("gas", "gamma"))) {
Expand Down Expand Up @@ -131,10 +137,12 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin,
const Real ldmax = pin->GetOrAddReal(block_name, "ldmax", -3);
const int nd = pin->GetOrAddInteger(block_name, "nd", 100);
const int nt = pin->GetOrAddInteger(block_name, "nt", 100);
ArtemisEOS::IdealHHe eos_base(X, Y, ltmin, ltmax, nt, ldmin, ldmax, nd,
save_to_file, true);
eos_base.SetFloors(siefloor, 0.0, dfloor, 0.0);

EOS eos_host = singularity::UnitSystem<ArtemisEOS::IdealHHe>(
ArtemisEOS::IdealHHe(X, Y, ltmin, ltmax, nt, ldmin, ldmax, nd, save_to_file,
true),
singularity::eos_units_init::LengthTimeUnitsInit(),
std::move(eos_base), singularity::eos_units_init::LengthTimeUnitsInit(),
units.GetTimeCodeToPhysical(), units.GetMassCodeToPhysical(),
units.GetLengthCodeToPhysical(), units.GetTemperatureCodeToPhysical());
EOS eos_device = eos_host.GetOnDevice();
Expand Down Expand Up @@ -293,12 +301,6 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin,
params.Add("scattering_h", scattering);
params.Add("scattering_d", scattering.GetOnDevice());

// Floors
const Real dfloor = pin->GetOrAddReal("gas", "dfloor", 1.0e-20);
const Real siefloor = pin->GetOrAddReal("gas", "siefloor", 1.0e-20);
params.Add("dfloor", dfloor);
params.Add("siefloor", siefloor);

// Dual energy switch
// When internal > de_switch * total we use the total
// The default turns off the switch
Expand Down
2 changes: 2 additions & 0 deletions src/pgen/beam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ inline void BeamInnerX2(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse)
using parthenon::MakePackDescriptor;
using TE = parthenon::TopologicalElement;
auto pmb = mbd->GetBlockPointer();
if (coarse && !ArtemisUtils::CoarseNeighbor(pmb)) return;

// Extract artemis package and params
auto artemis_pkg = pmb->packages.Get("artemis");
Expand Down Expand Up @@ -203,6 +204,7 @@ inline void BeamInnerX1(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse)
using parthenon::MakePackDescriptor;
using TE = parthenon::TopologicalElement;
auto pmb = mbd->GetBlockPointer();
if (coarse && !ArtemisUtils::CoarseNeighbor(pmb)) return;

// Extract artemis package and params
auto artemis_pkg = pmb->packages.Get("artemis");
Expand Down
3 changes: 3 additions & 0 deletions src/pgen/conduction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ template <Coordinates GEOM, IndexDomain BDY, Diffusion::DiffType DTYP>
void CondBoundaryImpl(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse) {
PARTHENON_INSTRUMENT
auto pmb = mbd->GetBlockPointer();
if (coarse && !ArtemisUtils::CoarseNeighbor(pmb)) return;

// Artemis package and params
auto artemis_pkg = pmb->packages.Get("artemis");
Expand Down Expand Up @@ -266,6 +267,8 @@ template <Coordinates GEOM, IndexDomain BDY>
inline void CondBoundary(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse) {
PARTHENON_INSTRUMENT
auto pmb = mbd->GetBlockPointer();
if (coarse && !ArtemisUtils::CoarseNeighbor(pmb)) return;

auto artemis_pkg = pmb->packages.Get("artemis");
auto &pkg = pmb->packages.Get("gas");

Expand Down
5 changes: 4 additions & 1 deletion src/pgen/disk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ void DiskBoundaryVisc(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse) {
"Viscous boundary conditions only work with spherical/cylindrical "
"radial boundaries");
auto pmb = mbd->GetBlockPointer();
if (coarse && !ArtemisUtils::CoarseNeighbor(pmb)) return;

// Extract artemis apackage and params
auto artemis_pkg = pmb->packages.Get("artemis");
Expand Down Expand Up @@ -638,6 +639,7 @@ template <Coordinates GEOM, IndexDomain BDY>
void DiskBoundaryIC(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse) {
PARTHENON_INSTRUMENT
auto pmb = mbd->GetBlockPointer();
if (coarse && !ArtemisUtils::CoarseNeighbor(pmb)) return;

auto artemis_pkg = pmb->packages.Get("artemis");
auto disk_params = artemis_pkg->Param<DiskParams>("disk_params");
Expand Down Expand Up @@ -677,10 +679,11 @@ void DiskBoundaryIC(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse) {
template <Coordinates GEOM, IndexDomain BDY>
void DiskBoundaryExtrap(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse) {
PARTHENON_INSTRUMENT
const bool lnx = (GEOM != Coordinates::cartesian);

auto pmb = mbd->GetBlockPointer();
if (coarse && !ArtemisUtils::CoarseNeighbor(pmb)) return;

const bool lnx = (GEOM != Coordinates::cartesian);
// Extract artemis parameters
auto artemis_pkg = pmb->packages.Get("artemis");
const bool do_gas = artemis_pkg->Param<bool>("do_gas");
Expand Down
2 changes: 2 additions & 0 deletions src/pgen/shock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ inline void ShockInnerX1(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse)
using parthenon::MakePackDescriptor;
using TE = parthenon::TopologicalElement;
auto pmb = mbd->GetBlockPointer();
if (coarse && !ArtemisUtils::CoarseNeighbor(pmb)) return;

auto artemis_pkg = pmb->packages.Get("artemis");
const bool do_moment = artemis_pkg->Param<bool>("do_moment");
Expand Down Expand Up @@ -194,6 +195,7 @@ inline void ShockOuterX1(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse)
using parthenon::MakePackDescriptor;
using TE = parthenon::TopologicalElement;
auto pmb = mbd->GetBlockPointer();
if (coarse && !ArtemisUtils::CoarseNeighbor(pmb)) return;

auto artemis_pkg = pmb->packages.Get("artemis");
const bool do_moment = artemis_pkg->Param<bool>("do_moment");
Expand Down
13 changes: 8 additions & 5 deletions src/pgen/strat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,17 @@ Real InitialDensity(const EOS &eos, const StratParams &pars, const Real z) {
if ((pars.three_d) && (std::abs(z) > 1e-16)) {
const Real dz = std::abs(z) / static_cast<Real>(pars.npoints);
const Real dlnr = 1e-6;
const Real ldmin = std::log(pars.dfloor / pars.rho0);
Real pres = eos.PressureFromDensityTemperature(dens, pars.temp0);
Real zj = 0.0;
Real ld = 0.0;
dens = std::exp(ld);
dens = pars.rho0 * std::exp(ld);
for (int j = 0; j < pars.npoints; j++) {
// ln(d/d0) = \int_0^z - Omega^2 z dz
Real pp = eos.PressureFromDensityTemperature(dens * (1. + dlnr), pars.temp0);
Real pm = eos.PressureFromDensityTemperature(dens * (1. - dlnr), pars.temp0);
Real dPdrho = (pp - pm) / (dlnr * dens);
ld -= 0.5 * pars.Om0 * (2 * j + 1) * SQR(dz) / (dPdrho + Fuzz<Real>());
dens = std::exp(ld);
dens = pars.rho0 * std::exp(ld);
if (dens <= pars.dfloor) return pars.dfloor;
}
}
Expand Down Expand Up @@ -228,6 +227,7 @@ inline void ExtrapInnerX1(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse
using parthenon::MakePackDescriptor;
using TE = parthenon::TopologicalElement;
auto pmb = mbd->GetBlockPointer();
if (coarse && !ArtemisUtils::CoarseNeighbor(pmb)) return;

// Packing
static auto descriptors = ArtemisUtils::GetBoundaryPackDescriptorMap<
Expand Down Expand Up @@ -321,6 +321,7 @@ inline void ExtrapOuterX1(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse
using parthenon::MakePackDescriptor;
using TE = parthenon::TopologicalElement;
auto pmb = mbd->GetBlockPointer();
if (coarse && !ArtemisUtils::CoarseNeighbor(pmb)) return;

// Packing
static auto descriptors = ArtemisUtils::GetBoundaryPackDescriptorMap<
Expand Down Expand Up @@ -429,6 +430,7 @@ inline void ShearInnerX2(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse)
using parthenon::MakePackDescriptor;
using TE = parthenon::TopologicalElement;
auto pmb = mbd->GetBlockPointer();
if (coarse && !ArtemisUtils::CoarseNeighbor(pmb)) return;

// Packing
static auto descriptors = ArtemisUtils::GetBoundaryPackDescriptorMap<
Expand Down Expand Up @@ -551,6 +553,7 @@ inline void ShearOuterX2(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse)
using parthenon::MakePackDescriptor;
using TE = parthenon::TopologicalElement;
auto pmb = mbd->GetBlockPointer();
if (coarse && !ArtemisUtils::CoarseNeighbor(pmb)) return;

// Packing
static auto descriptors = ArtemisUtils::GetBoundaryPackDescriptorMap<
Expand Down Expand Up @@ -600,7 +603,6 @@ inline void ShearOuterX2(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse)
const Real vx3g = outflow ? gv3 : 0.0;
const Real densg =
outflow ? v(0, gas::prim::density(n), k, je, i) : InitialDensity(pars, z);
;
const Real sieg = outflow ? v(0, gas::prim::sie(n), k, je, i)
: std::max(pars.siefloor,
eos_d.InternalEnergyFromDensityTemperature(
Expand Down Expand Up @@ -661,6 +663,7 @@ inline void ExtrapInnerX3(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse
using parthenon::MakePackDescriptor;
using TE = parthenon::TopologicalElement;
auto pmb = mbd->GetBlockPointer();
if (coarse && !ArtemisUtils::CoarseNeighbor(pmb)) return;

// Packing
static auto descriptors = ArtemisUtils::GetBoundaryPackDescriptorMap<
Expand Down Expand Up @@ -707,7 +710,6 @@ inline void ExtrapInnerX3(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse
const Real &gd = v(0, gas::prim::density(n), ks, j, i);
const Real &gsie = v(0, gas::prim::sie(n), ks, j, i);
const Real Tg = eos_d.TemperatureFromDensityInternalEnergy(gd, gsie);

const Real pm = eos_d.PressureFromDensityTemperature(gd * (1. - 1e-6), Tg);
const Real pp = eos_d.PressureFromDensityTemperature(gd * (1. + 1e-6), Tg);
const Real dPdrho = (pp - pm) / (gd * 1e-6);
Expand Down Expand Up @@ -764,6 +766,7 @@ inline void ExtrapOuterX3(std::shared_ptr<MeshBlockData<Real>> &mbd, bool coarse
using parthenon::MakePackDescriptor;
using TE = parthenon::TopologicalElement;
auto pmb = mbd->GetBlockPointer();
if (coarse && !ArtemisUtils::CoarseNeighbor(pmb)) return;

// Packing
static auto descriptors = ArtemisUtils::GetBoundaryPackDescriptorMap<
Expand Down
12 changes: 12 additions & 0 deletions src/utils/artemis_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,16 @@ ReconstructionMethod ChooseReconMethod(std::string recon) {
return ReconstructionMethod::pcm;
}

bool CoarseNeighbor(MeshBlock *pmb) {
bool has_coarser = false;
const int mylevel = pmb->loc.level();
for (const auto &nb : pmb->neighbors) {
if (nb.origin_loc.level() < mylevel) {
has_coarser = true;
break;
}
}
return has_coarser;
}

} // namespace ArtemisUtils
2 changes: 2 additions & 0 deletions src/utils/artemis_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ Real CutCell2D(const std::array<Real, 4> &x, const std::array<Real, 4> &y,
return vol_inside / vol;
}

bool CoarseNeighbor(MeshBlock *pmb);

} // namespace ArtemisUtils

#endif // UTILS_ARTEMIS_UTILS_HPP_
Loading