Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't assume <jaybenne> #1

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
29 changes: 15 additions & 14 deletions src/jaybenne/jaybenne.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,26 +130,27 @@ TaskCollection RadiationStep(Mesh *pmesh, const Real t_start, const Real dt) {
//! parameters associated with Jaybenne, and enrolls the data variables associated with
//! this physics package.
std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin, Opacity &opacity,
Scattering &scattering, EOS &eos) {
Scattering &scattering, EOS &eos,
std::string block_name) {
auto pkg = std::make_shared<StateDescriptor>("jaybenne");
RyanWollaeger marked this conversation as resolved.
Show resolved Hide resolved

// Total number of particles
int num_particles = pin->GetInteger("jaybenne", "num_particles");
int num_particles = pin->GetInteger(block_name, "num_particles");
pkg->AddParam<>("num_particles", num_particles);
Real dt = pin->GetOrAddReal("jaybenne", "dt", std::numeric_limits<Real>::max());
Real dt = pin->GetOrAddReal(block_name, "dt", std::numeric_limits<Real>::max());
pkg->AddParam<>("dt", dt);

// Minimum occupancy of swarm (measure of pool fragmentation) below which
// defragmentation is triggered.
Real min_swarm_occupancy = pin->GetOrAddReal("jaybenne", "min_swarm_occupancy", 0.);
Real min_swarm_occupancy = pin->GetOrAddReal(block_name, "min_swarm_occupancy", 0.);
PARTHENON_REQUIRE(min_swarm_occupancy >= 0 && min_swarm_occupancy < 1.0,
"Minimum allowable swarm occupancy must be >= 0 and less than 1");
pkg->AddParam<>("min_swarm_occupancy", min_swarm_occupancy);

// Frequency range
Real numin = pin->GetOrAddReal("jaybenne", "numin", std::numeric_limits<Real>::min());
Real numin = pin->GetOrAddReal(block_name, "numin", std::numeric_limits<Real>::min());
pkg->AddParam<>("numin", numin);
Real numax = pin->GetOrAddReal("jaybenne", "numax", std::numeric_limits<Real>::max());
Real numax = pin->GetOrAddReal(block_name, "numax", std::numeric_limits<Real>::max());
pkg->AddParam<>("numax", numax);

// Physical constants
Expand All @@ -158,28 +159,28 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin, Opacity &opacit
pkg->AddParam<>("stefan_boltzmann", units.sb);

// RNG
bool unique_rank_seeds = pin->GetOrAddBoolean("jaybenne", "unique_rank_seeds", true);
bool unique_rank_seeds = pin->GetOrAddBoolean(block_name, "unique_rank_seeds", true);
pkg->AddParam<>("unique_rank_seeds", unique_rank_seeds);
int seed = pin->GetOrAddInteger("jaybenne", "seed", 123);
int seed = pin->GetOrAddInteger(block_name, "seed", 123);
pkg->AddParam<>("seed", unique_rank_seeds ? seed + Globals::my_rank : seed);
RngPool rng_pool(seed);
pkg->AddParam<>("rng_pool", rng_pool);

// Transport numerics
int max_transport_iterations =
pin->GetOrAddInteger("jaybenne", "max_transport_iterations", 10000);
pin->GetOrAddInteger(block_name, "max_transport_iterations", 10000);
pkg->AddParam<>("max_transport_iterations", max_transport_iterations);

// DDMC flag (0 = no DDMC)
bool use_ddmc = pin->GetOrAddBoolean("jaybenne", "use_ddmc", false);
bool use_ddmc = pin->GetOrAddBoolean(block_name, "use_ddmc", false);
pkg->AddParam<>("use_ddmc", use_ddmc);
// parse or use default DDMC threshold = 5
Real tau_ddmc = pin->GetOrAddReal("jaybenne", "tau_ddmc", 5.0);
Real tau_ddmc = pin->GetOrAddReal(block_name, "tau_ddmc", 5.0);
pkg->AddParam<>("tau_ddmc", tau_ddmc);

// Sourcing strategy
SourceStrategy source_strategy;
std::string strategy = pin->GetOrAddString("jaybenne", "source_strategy", "uniform");
std::string strategy = pin->GetOrAddString(block_name, "source_strategy", "uniform");
if (strategy == "uniform") {
source_strategy = SourceStrategy::uniform;
} else if (strategy == "energy") {
Expand All @@ -190,11 +191,11 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin, Opacity &opacit
pkg->AddParam<>("source_strategy", source_strategy);

// Whether to include emission physics
const bool do_emission = pin->GetOrAddBoolean("jaybenne", "do_emission", true);
const bool do_emission = pin->GetOrAddBoolean(block_name, "do_emission", true);
pkg->AddParam<>("do_emission", do_emission);

// Whether to feedback on fluid
const bool do_feedback = pin->GetOrAddBoolean("jaybenne", "do_feedback", true);
const bool do_feedback = pin->GetOrAddBoolean(block_name, "do_feedback", true);
pkg->AddParam<>("do_feedback", do_feedback);

// Equation of state model
Expand Down
6 changes: 3 additions & 3 deletions src/jaybenne/jaybenne.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ using namespace parthenon::package::prelude;

namespace jaybenne {

std::shared_ptr<parthenon::StateDescriptor> Initialize(parthenon::ParameterInput *pin,
Opacity &opacity,
Scattering &scattering, EOS &eos);
std::shared_ptr<parthenon::StateDescriptor>
Initialize(parthenon::ParameterInput *pin, Opacity &opacity, Scattering &scattering,
EOS &eos, std::string block_name = "jaybenne");

// Model enums
enum class SourceStrategy { uniform, energy };
Expand Down