Skip to content

Commit

Permalink
only add face velocities if hydro is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWibking committed Jan 15, 2024
1 parent 3b60b53 commit 86cd997
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/physics_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ template <typename problem_t> struct Physics_Indices {
static const int pscalarFirstIndex = Physics_NumVars::numHydroVars;
static const int radFirstIndex = pscalarFirstIndex + Physics_Traits<problem_t>::numPassiveScalars;
// face-centered
static const int nvarPerDim_fc =
Physics_NumVars::numVelVars_per_dim + Physics_NumVars::numMHDVars_per_dim * static_cast<int>(Physics_Traits<problem_t>::is_mhd_enabled);
static const int nvarPerDim_fc = Physics_NumVars::numVelVars_per_dim * static_cast<int>(Physics_Traits<problem_t>::is_hydro_enabled) +
Physics_NumVars::numMHDVars_per_dim * static_cast<int>(Physics_Traits<problem_t>::is_mhd_enabled);
static const int nvarTotal_fc = AMREX_SPACEDIM * nvarPerDim_fc;
static const int velFirstIndex = 0;
static const int mhdFirstIndex = velFirstIndex + Physics_NumVars::numVelVars_per_dim;
Expand Down
32 changes: 17 additions & 15 deletions src/simulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,24 @@ template <typename problem_t> class AMRSimulation : public amrex::AmrCore

inline auto builtin_BCs_fc(amrex::Vector<amrex::BCRec> &BCs_cc) -> amrex::Vector<amrex::BCRec>
{
AMREX_ALWAYS_ASSERT(Physics_Indices<problem_t>::nvarPerDim_fc == 1);

// set boundary conditions for face velocities (used ONLY for tracer particles)
amrex::Vector<amrex::BCRec> BCs_fc(Physics_Indices<problem_t>::nvarPerDim_fc);
for (int i = 0; i < AMREX_SPACEDIM; ++i) {
// lower boundary
if (BCs_cc[Physics_Indices<problem_t>::hydroFirstIndex].lo(i) == amrex::BCType::int_dir) {
BCs_fc[Physics_Indices<problem_t>::velFirstIndex].setLo(i, amrex::BCType::int_dir);
} else {
BCs_fc[Physics_Indices<problem_t>::velFirstIndex].setLo(i, amrex::BCType::foextrap);
}
// upper boundary
if (BCs_cc[Physics_Indices<problem_t>::hydroFirstIndex].hi(i) == amrex::BCType::int_dir) {
BCs_fc[Physics_Indices<problem_t>::velFirstIndex].setHi(i, amrex::BCType::int_dir);
} else {
BCs_fc[Physics_Indices<problem_t>::velFirstIndex].setHi(i, amrex::BCType::foextrap);

if (Physics_Traits<problem_t>::is_hydro_enabled) {
AMREX_ALWAYS_ASSERT(Physics_Indices<problem_t>::nvarPerDim_fc == 1);
// set boundary conditions for face velocities (used ONLY for tracer particles)
for (int i = 0; i < AMREX_SPACEDIM; ++i) {
// lower boundary
if (BCs_cc[Physics_Indices<problem_t>::hydroFirstIndex].lo(i) == amrex::BCType::int_dir) {
BCs_fc[Physics_Indices<problem_t>::velFirstIndex].setLo(i, amrex::BCType::int_dir);
} else {
BCs_fc[Physics_Indices<problem_t>::velFirstIndex].setLo(i, amrex::BCType::foextrap);
}
// upper boundary
if (BCs_cc[Physics_Indices<problem_t>::hydroFirstIndex].hi(i) == amrex::BCType::int_dir) {
BCs_fc[Physics_Indices<problem_t>::velFirstIndex].setHi(i, amrex::BCType::int_dir);
} else {
BCs_fc[Physics_Indices<problem_t>::velFirstIndex].setHi(i, amrex::BCType::foextrap);
}
}
}
return BCs_fc;
Expand Down

0 comments on commit 86cd997

Please sign in to comment.