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

use anon namespace instead of static in Castro_setup.cpp #2786

Merged
merged 3 commits into from
Mar 21, 2024
Merged
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
216 changes: 116 additions & 100 deletions Source/driver/Castro_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,137 +20,153 @@
using std::string;
using namespace amrex;

static Box the_same_box (const Box& b) { return b; }
static Box grow_box_by_one (const Box& b) { return amrex::grow(b,1); }
using BndryFunc = StateDescriptor::BndryFunc;

typedef StateDescriptor::BndryFunc BndryFunc;
namespace {

//
// Components are:
// Interior, Inflow, Outflow, Symmetry, SlipWall, NoSlipWall
//
static int scalar_bc[] =
{
amrex::BCType::int_dir, amrex::BCType::ext_dir, amrex::BCType::foextrap, amrex::BCType::reflect_even, amrex::BCType::reflect_even, amrex::BCType::reflect_even
};

static int norm_vel_bc[] =
{
amrex::BCType::int_dir, amrex::BCType::ext_dir, amrex::BCType::foextrap, amrex::BCType::reflect_odd, amrex::BCType::reflect_odd, amrex::BCType::reflect_odd
};
Box the_same_box (const Box& b) { return b; }
Box grow_box_by_one (const Box& b) { return amrex::grow(b,1); }

static int tang_vel_bc[] =
{
amrex::BCType::int_dir, amrex::BCType::ext_dir, amrex::BCType::foextrap, amrex::BCType::reflect_even, amrex::BCType::reflect_even, amrex::BCType::reflect_even
};
//
// Components are:
// Interior, Inflow, Outflow, Symmetry, SlipWall, NoSlipWall
//
int scalar_bc[] =
{
amrex::BCType::int_dir,
amrex::BCType::ext_dir,
amrex::BCType::foextrap,
amrex::BCType::reflect_even,
amrex::BCType::reflect_even,
amrex::BCType::reflect_even
};

int norm_vel_bc[] =
{
amrex::BCType::int_dir,
amrex::BCType::ext_dir,
amrex::BCType::foextrap,
amrex::BCType::reflect_odd,
amrex::BCType::reflect_odd,
amrex::BCType::reflect_odd
};

int tang_vel_bc[] =
{
amrex::BCType::int_dir,
amrex::BCType::ext_dir,
amrex::BCType::foextrap,
amrex::BCType::reflect_even,
amrex::BCType::reflect_even,
amrex::BCType::reflect_even
};

#ifdef MHD
static int mag_field_bc[] =
{
amrex::BCType::int_dir, amrex::BCType::ext_dir, amrex::BCType::foextrap, amrex::BCType::reflect_even, amrex::BCType::foextrap, amrex::BCType::hoextrap
};
int mag_field_bc[] =
{
amrex::BCType::int_dir,
amrex::BCType::ext_dir,
amrex::BCType::foextrap,
amrex::BCType::reflect_even,
amrex::BCType::foextrap,
amrex::BCType::hoextrap
};
#endif

static
void
set_scalar_bc (BCRec& bc, const BCRec& phys_bc)
{
const int* lo_bc = phys_bc.lo();
const int* hi_bc = phys_bc.hi();
for (int i = 0; i < AMREX_SPACEDIM; i++)
void
set_scalar_bc (BCRec& bc, const BCRec& phys_bc)
{
bc.setLo(i,scalar_bc[lo_bc[i]]);
bc.setHi(i,scalar_bc[hi_bc[i]]);
const int* lo_bc = phys_bc.lo();
const int* hi_bc = phys_bc.hi();
for (int i = 0; i < AMREX_SPACEDIM; i++)
{
bc.setLo(i,scalar_bc[lo_bc[i]]);
bc.setHi(i,scalar_bc[hi_bc[i]]);
}
}
}

static
void
set_x_vel_bc(BCRec& bc, const BCRec& phys_bc)
{
const int* lo_bc = phys_bc.lo();
const int* hi_bc = phys_bc.hi();
bc.setLo(0,norm_vel_bc[lo_bc[0]]);
bc.setHi(0,norm_vel_bc[hi_bc[0]]);
void
set_x_vel_bc(BCRec& bc, const BCRec& phys_bc)
{
const int* lo_bc = phys_bc.lo();
const int* hi_bc = phys_bc.hi();
bc.setLo(0,norm_vel_bc[lo_bc[0]]);
bc.setHi(0,norm_vel_bc[hi_bc[0]]);
#if (AMREX_SPACEDIM >= 2)
bc.setLo(1,tang_vel_bc[lo_bc[1]]);
bc.setHi(1,tang_vel_bc[hi_bc[1]]);
bc.setLo(1,tang_vel_bc[lo_bc[1]]);
bc.setHi(1,tang_vel_bc[hi_bc[1]]);
#endif
#if (AMREX_SPACEDIM == 3)
bc.setLo(2,tang_vel_bc[lo_bc[2]]);
bc.setHi(2,tang_vel_bc[hi_bc[2]]);
bc.setLo(2,tang_vel_bc[lo_bc[2]]);
bc.setHi(2,tang_vel_bc[hi_bc[2]]);
#endif
}
}

static
void
set_y_vel_bc(BCRec& bc, const BCRec& phys_bc)
{
const int* lo_bc = phys_bc.lo();
const int* hi_bc = phys_bc.hi();
bc.setLo(0,tang_vel_bc[lo_bc[0]]);
bc.setHi(0,tang_vel_bc[hi_bc[0]]);
void
set_y_vel_bc(BCRec& bc, const BCRec& phys_bc)
{
const int* lo_bc = phys_bc.lo();
const int* hi_bc = phys_bc.hi();
bc.setLo(0,tang_vel_bc[lo_bc[0]]);
bc.setHi(0,tang_vel_bc[hi_bc[0]]);
#if (AMREX_SPACEDIM >= 2)
bc.setLo(1,norm_vel_bc[lo_bc[1]]);
bc.setHi(1,norm_vel_bc[hi_bc[1]]);
bc.setLo(1,norm_vel_bc[lo_bc[1]]);
bc.setHi(1,norm_vel_bc[hi_bc[1]]);
#endif
#if (AMREX_SPACEDIM == 3)
bc.setLo(2,tang_vel_bc[lo_bc[2]]);
bc.setHi(2,tang_vel_bc[hi_bc[2]]);
bc.setLo(2,tang_vel_bc[lo_bc[2]]);
bc.setHi(2,tang_vel_bc[hi_bc[2]]);
#endif
}
}

static
void
set_z_vel_bc(BCRec& bc, const BCRec& phys_bc)
{
const int* lo_bc = phys_bc.lo();
const int* hi_bc = phys_bc.hi();
bc.setLo(0,tang_vel_bc[lo_bc[0]]);
bc.setHi(0,tang_vel_bc[hi_bc[0]]);
void
set_z_vel_bc(BCRec& bc, const BCRec& phys_bc)
{
const int* lo_bc = phys_bc.lo();
const int* hi_bc = phys_bc.hi();
bc.setLo(0,tang_vel_bc[lo_bc[0]]);
bc.setHi(0,tang_vel_bc[hi_bc[0]]);
#if (AMREX_SPACEDIM >= 2)
bc.setLo(1,tang_vel_bc[lo_bc[1]]);
bc.setHi(1,tang_vel_bc[hi_bc[1]]);
bc.setLo(1,tang_vel_bc[lo_bc[1]]);
bc.setHi(1,tang_vel_bc[hi_bc[1]]);
#endif
#if (AMREX_SPACEDIM == 3)
bc.setLo(2,norm_vel_bc[lo_bc[2]]);
bc.setHi(2,norm_vel_bc[hi_bc[2]]);
bc.setLo(2,norm_vel_bc[lo_bc[2]]);
bc.setHi(2,norm_vel_bc[hi_bc[2]]);
#endif
}

}

#ifdef MHD
static
void
set_mag_field_bc(BCRec& bc, const BCRec& phys_bc)
{
const int* lo_bc = phys_bc.lo();
const int* hi_bc = phys_bc.hi();
for (int i = 0; i < AMREX_SPACEDIM; i++)
void
set_mag_field_bc(BCRec& bc, const BCRec& phys_bc)
{
bc.setLo(i, mag_field_bc[lo_bc[i]]);
bc.setHi(i, mag_field_bc[hi_bc[i]]);
const int* lo_bc = phys_bc.lo();
const int* hi_bc = phys_bc.hi();
for (int i = 0; i < AMREX_SPACEDIM; i++)
{
bc.setLo(i, mag_field_bc[lo_bc[i]]);
bc.setHi(i, mag_field_bc[hi_bc[i]]);
}
}
}
#endif

// In some cases we want to replace inflow boundaries with
// first-order extrapolation boundaries. This is intended to
// be used for state data that the user is not going to
// provide inflow boundary conditions for, like gravity
// and reactions, and it works in conjunction with the
// generic_fill boundary routine.
// In some cases we want to replace inflow boundaries with
// first-order extrapolation boundaries. This is intended to
// be used for state data that the user is not going to
// provide inflow boundary conditions for, like gravity
// and reactions, and it works in conjunction with the
// generic_fill boundary routine.

static
void
replace_inflow_bc (BCRec& bc)
{
for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
if (bc.lo(dir) == amrex::BCType::ext_dir) {
bc.setLo(dir, amrex::BCType::foextrap);
}
if (bc.hi(dir) == amrex::BCType::ext_dir) {
bc.setHi(dir, amrex::BCType::foextrap);
void
replace_inflow_bc (BCRec& bc)
{
for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
if (bc.lo(dir) == amrex::BCType::ext_dir) {
bc.setLo(dir, amrex::BCType::foextrap);
}
if (bc.hi(dir) == amrex::BCType::ext_dir) {
bc.setHi(dir, amrex::BCType::foextrap);
}
}
}
}
Expand Down