Skip to content

Commit

Permalink
cpp-py-formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
par-hermes committed Aug 29, 2023
1 parent 6853b2d commit 60551ed
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/hydro/hydro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ TaskStatus CalculateFluxes(std::shared_ptr<MeshData<Real>> &md) {
jl = jb.s, ju = jb.e, kl = kb.s, ku = kb.e;
// TODO(pgrete): are these looop limits are likely too large for 2nd order
if (pmb->block_size.nx(X2DIR) > 1) {
if (pmb->block_size.nx(X3DIR)== 1) // 2D
if (pmb->block_size.nx(X3DIR) == 1) // 2D
jl = jb.s - 1, ju = jb.e + 1, kl = kb.s, ku = kb.e;
else // 3D
jl = jb.s - 1, ju = jb.e + 1, kl = kb.s - 1, ku = kb.e + 1;
Expand Down
49 changes: 23 additions & 26 deletions src/pgen/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ using namespace parthenon::driver::prelude;
using namespace parthenon::package::prelude;
using utils::few_modes_ft::FewModesFT;


void ClusterUnsplitSrcTerm(MeshData<Real> *md, const parthenon::SimTime &tm,
const Real beta_dt) {
const Real beta_dt) {
auto hydro_pkg = md->GetBlockData(0)->GetBlockPointer()->packages.Get("Hydro");

const bool &gravity_srcterm = hydro_pkg->Param<bool>("gravity_srcterm");
Expand All @@ -79,17 +78,16 @@ void ClusterUnsplitSrcTerm(MeshData<Real> *md, const parthenon::SimTime &tm,
const auto &magnetic_tower = hydro_pkg->Param<MagneticTower>("magnetic_tower");
magnetic_tower.FixedFieldSrcTerm(md, beta_dt, tm);

//const auto &snia_feedback = hydro_pkg->Param<SNIAFeedback>("snia_feedback");
//snia_feedback.FeedbackSrcTerm(md, beta_dt, tm);
// const auto &snia_feedback = hydro_pkg->Param<SNIAFeedback>("snia_feedback");
// snia_feedback.FeedbackSrcTerm(md, beta_dt, tm);

//ApplyClusterClips(md, tm, beta_dt);
// ApplyClusterClips(md, tm, beta_dt);

const auto &stellar_feedback = hydro_pkg->Param<StellarFeedback>("stellar_feedback");
stellar_feedback.FeedbackSrcTerm(md, beta_dt, tm);

};
void ClusterSplitSrcTerm(MeshData<Real> *md, const parthenon::SimTime &tm,
const Real dt) {
const Real dt) {
auto hydro_pkg = md->GetBlockData(0)->GetBlockPointer()->packages.Get("Hydro");

const auto &stellar_feedback = hydro_pkg->Param<StellarFeedback>("stellar_feedback");
Expand Down Expand Up @@ -295,50 +293,49 @@ void ProblemInitPackageData(ParameterInput *pin, parthenon::StateDescriptor *hyd
made and a history output is not, then the mass/energy between the last
history output and the restart dump is lost
*/
std::string reduction_strs[] = {"stellar_mass","added_dfloor_mass", "removed_eceil_energy",
"removed_vceil_energy", "added_vAceil_mass"};
std::string reduction_strs[] = {"stellar_mass", "added_dfloor_mass",
"removed_eceil_energy", "removed_vceil_energy",
"added_vAceil_mass"};

//Add a param for each reduction, then add it as a summation reduction for
//history outputs
// Add a param for each reduction, then add it as a summation reduction for
// history outputs
auto hst_vars = hydro_pkg->Param<parthenon::HstVar_list>(parthenon::hist_param_key);

for( auto reduction_str : reduction_strs ) {
hydro_pkg->AddParam(reduction_str, 0.0, true);
for (auto reduction_str : reduction_strs) {
hydro_pkg->AddParam(reduction_str, 0.0, true);
hst_vars.emplace_back(parthenon::HistoryOutputVar(
parthenon::UserHistoryOperation::sum,
[reduction_str](MeshData<Real> *md) {
auto pmb = md->GetBlockData(0)->GetBlockPointer();
auto hydro_pkg = pmb->packages.Get("Hydro");
const Real reduction = hydro_pkg->Param<Real>(reduction_str);
//Reset the running count for this reduction between history outputs
hydro_pkg->UpdateParam(reduction_str,0.0);
// Reset the running count for this reduction between history outputs
hydro_pkg->UpdateParam(reduction_str, 0.0);
return reduction;
},
reduction_str));
}

//Add history reduction for total cold gas using stellar mass threshold
// Add history reduction for total cold gas using stellar mass threshold
const Real cold_thresh =
pin->GetOrAddReal("problem/cluster/reductions", "cold_temp_thresh", 0.0);
if( cold_thresh > 0){
if (cold_thresh > 0) {
hydro_pkg->AddParam("reduction_cold_threshold", cold_thresh);
hst_vars.emplace_back(parthenon::HistoryOutputVar(
parthenon::UserHistoryOperation::sum, LocalReduceColdGas,
"cold_mass"));
parthenon::UserHistoryOperation::sum, LocalReduceColdGas, "cold_mass"));
}
const Real agn_tracer_thresh =
pin->GetOrAddReal("problem/cluster/reductions", "agn_tracer_thresh", -1.0);
if( agn_tracer_thresh >= 0){
auto mbar_over_kb = hydro_pkg->Param<Real>("mbar_over_kb");
PARTHENON_REQUIRE(pin->GetOrAddBoolean("problem/cluster/agn_feedback", "enable_tracer", false),
"AGN Tracer must be enabled to reduce AGN tracer extent");
if (agn_tracer_thresh >= 0) {
auto mbar_over_kb = hydro_pkg->Param<Real>("mbar_over_kb");
PARTHENON_REQUIRE(
pin->GetOrAddBoolean("problem/cluster/agn_feedback", "enable_tracer", false),
"AGN Tracer must be enabled to reduce AGN tracer extent");
hydro_pkg->AddParam("reduction_agn_tracer_threshold", agn_tracer_thresh);
hst_vars.emplace_back(parthenon::HistoryOutputVar(
parthenon::UserHistoryOperation::max, LocalReduceAGNExtent,
"agn_extent"));
parthenon::UserHistoryOperation::max, LocalReduceAGNExtent, "agn_extent"));
}


hydro_pkg->UpdateParam(parthenon::hist_param_key, hst_vars);

/************************************************************
Expand Down
9 changes: 6 additions & 3 deletions src/pgen/field_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,16 @@ void ProblemGenerator(MeshBlock *pmb, ParameterInput *pin) {
int iprob = pin->GetInteger("problem/field_loop", "iprob");
Real ang_2, cos_a2(0.0), sin_a2(0.0), lambda(0.0);

Real x1size = pmb->pmy_mesh->mesh_size.xmax(X1DIR) - pmb->pmy_mesh->mesh_size.xmin(X1DIR);
Real x2size = pmb->pmy_mesh->mesh_size.xmax(X2DIR) - pmb->pmy_mesh->mesh_size.xmin(X2DIR);
Real x1size =
pmb->pmy_mesh->mesh_size.xmax(X1DIR) - pmb->pmy_mesh->mesh_size.xmin(X1DIR);
Real x2size =
pmb->pmy_mesh->mesh_size.xmax(X2DIR) - pmb->pmy_mesh->mesh_size.xmin(X2DIR);

const bool two_d = pmb->pmy_mesh->ndim < 3;
// for 2D sim set x3size to zero so that v_z is 0 below
Real x3size =
two_d ? 0 : pmb->pmy_mesh->mesh_size.xmax(X3DIR) - pmb->pmy_mesh->mesh_size.xmin(X3DIR);
two_d ? 0
: pmb->pmy_mesh->mesh_size.xmax(X3DIR) - pmb->pmy_mesh->mesh_size.xmin(X3DIR);

// For (iprob=4) -- rotated cylinder in 3D -- set up rotation angle and wavelength
if (iprob == 4) {
Expand Down
9 changes: 6 additions & 3 deletions src/pgen/turbulence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,12 @@ void Perturb(MeshData<Real> *md, const Real dt) {
MPI_SUM, MPI_COMM_WORLD));
#endif // MPI_PARALLEL

const auto Lx = pmb->pmy_mesh->mesh_size.xmax(X1DIR) - pmb->pmy_mesh->mesh_size.xmin(X1DIR);
const auto Ly = pmb->pmy_mesh->mesh_size.xmax(X2DIR) - pmb->pmy_mesh->mesh_size.xmin(X2DIR);
const auto Lz = pmb->pmy_mesh->mesh_size.xmax(X3DIR) - pmb->pmy_mesh->mesh_size.xmin(X3DIR);
const auto Lx =
pmb->pmy_mesh->mesh_size.xmax(X1DIR) - pmb->pmy_mesh->mesh_size.xmin(X1DIR);
const auto Ly =
pmb->pmy_mesh->mesh_size.xmax(X2DIR) - pmb->pmy_mesh->mesh_size.xmin(X2DIR);
const auto Lz =
pmb->pmy_mesh->mesh_size.xmax(X3DIR) - pmb->pmy_mesh->mesh_size.xmin(X3DIR);
const auto accel_rms = hydro_pkg->Param<Real>("turbulence/accel_rms");
auto norm = accel_rms / std::sqrt(sums[0] / (Lx * Ly * Lz));

Expand Down

0 comments on commit 60551ed

Please sign in to comment.