Skip to content

Commit

Permalink
Merge pull request #253 from hklion/specify_bc_by_variable
Browse files Browse the repository at this point in the history
added more BC options and add option to specify it by variable
  • Loading branch information
hklion authored Aug 27, 2024
2 parents 31e526a + ba75622 commit 8732fa2
Show file tree
Hide file tree
Showing 15 changed files with 421 additions and 220 deletions.
8 changes: 4 additions & 4 deletions Exec/IdealMiniGrid/inputs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ geometry.is_periodic = 0 0 0
zlo.type = "SlipWall"
zhi.type = "SlipWall"

xlo.type = "outflow"
xhi.type = "outflow"
ylo.type = "outflow"
yhi.type = "outflow"
xlo.type = "clamped"
xhi.type = "clamped"
ylo.type = "clamped"
yhi.type = "clamped"

# TIME STEP CONTROL
remora.fixed_dt = 200.0 # Timestep size (seconds)
Expand Down
18 changes: 7 additions & 11 deletions Source/BoundaryConditions/REMORA_FillPatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ PhysBCFunctNoOp null_bc;
//
void
REMORA::FillPatch (int lev, Real time, MultiFab& mf_to_fill, Vector<MultiFab*> const& mfs,
const int bccomp,
#ifdef REMORA_USE_NETCDF
const int bdy_var_type,
#else
Expand All @@ -25,7 +26,6 @@ REMORA::FillPatch (int lev, Real time, MultiFab& mf_to_fill, Vector<MultiFab*> c
const int n_not_fill)
{
BL_PROFILE_VAR("REMORA::FillPatch()",REMORA_FillPatch);
int bccomp;
amrex::Interpolater* mapper = nullptr;

Box mf_box(mf_to_fill.boxArray()[0]);
Expand Down Expand Up @@ -72,24 +72,20 @@ REMORA::FillPatch (int lev, Real time, MultiFab& mf_to_fill, Vector<MultiFab*> c

if (mf_box.ixType() == IndexType(IntVect(0,0,0)))
{
bccomp = 0;
mapper = &cell_cons_interp;
mask = vec_mskr[lev].get();
}
else if (mf_box.ixType() == IndexType(IntVect(1,0,0)))
{
bccomp = BCVars::xvel_bc;
mapper = &face_linear_interp;
mask = vec_msku[lev].get();
}
else if (mf_box.ixType() == IndexType(IntVect(0,1,0)))
{
bccomp = BCVars::yvel_bc;
mapper = &face_linear_interp;
mask = vec_mskv[lev].get();
}
else {
bccomp = BCVars::zvel_bc;
mapper = &face_linear_interp;
mask = vec_mskr[lev].get();
}
Expand Down Expand Up @@ -425,7 +421,7 @@ REMORA::FillBdyCCVels (int lev, MultiFab& mf_cc_vel)
if (!Geom(lev).isPeriodic(0)) {
// Low-x side
if (bx.smallEnd(0) <= domain.smallEnd(0)) {
Real mult = (phys_bc_type[0] == REMORA_BC::no_slip_wall) ? -1. : 1.;
Real mult = (phys_bc_type[BCVars::xvel_bc][0] == REMORA_BC::no_slip_wall) ? -1. : 1.;
ParallelFor(makeSlab(bx,0,0), [=] AMREX_GPU_DEVICE(int , int j, int k) noexcept
{
vel_arr(-1,j,k,1) = mult*vel_arr(0,j,k,1); // v
Expand All @@ -435,7 +431,7 @@ REMORA::FillBdyCCVels (int lev, MultiFab& mf_cc_vel)

// High-x side
if (bx.bigEnd(0) >= domain.bigEnd(0)) {
Real mult = (phys_bc_type[3] == REMORA_BC::no_slip_wall) ? -1. : 1.;
Real mult = (phys_bc_type[BCVars::xvel_bc][3] == REMORA_BC::no_slip_wall) ? -1. : 1.;
ParallelFor(makeSlab(bx,0,0), [=] AMREX_GPU_DEVICE(int , int j, int k) noexcept
{
vel_arr(ihi+1,j,k,1) = mult*vel_arr(ihi,j,k,1); // v
Expand All @@ -447,7 +443,7 @@ REMORA::FillBdyCCVels (int lev, MultiFab& mf_cc_vel)
if (!Geom(lev).isPeriodic(1)) {
// Low-y side
if (bx.smallEnd(1) <= domain.smallEnd(1)) {
Real mult = (phys_bc_type[1] == REMORA_BC::no_slip_wall) ? -1. : 1.;
Real mult = (phys_bc_type[BCVars::yvel_bc][1] == REMORA_BC::no_slip_wall) ? -1. : 1.;
ParallelFor(makeSlab(bx,1,0), [=] AMREX_GPU_DEVICE(int i, int , int k) noexcept
{
vel_arr(i,-1,k,0) = mult*vel_arr(i,0,k,0); // u
Expand All @@ -457,7 +453,7 @@ REMORA::FillBdyCCVels (int lev, MultiFab& mf_cc_vel)

// High-y side
if (bx.bigEnd(1) >= domain.bigEnd(1)) {
Real mult = (phys_bc_type[4] == REMORA_BC::no_slip_wall) ? -1. : 1.;
Real mult = (phys_bc_type[BCVars::yvel_bc][4] == REMORA_BC::no_slip_wall) ? -1. : 1.;
ParallelFor(makeSlab(bx,1,0), [=] AMREX_GPU_DEVICE(int i, int , int k) noexcept
{
vel_arr(i,jhi+1,k,0) = mult*vel_arr(i,jhi,k,0); // u
Expand All @@ -469,7 +465,7 @@ REMORA::FillBdyCCVels (int lev, MultiFab& mf_cc_vel)
if (!Geom(lev).isPeriodic(2)) {
// Low-z side
if (bx.smallEnd(2) <= domain.smallEnd(2)) {
Real mult = (phys_bc_type[2] == REMORA_BC::no_slip_wall) ? -1. : 1.;
Real mult = (phys_bc_type[BCVars::zvel_bc][2] == REMORA_BC::no_slip_wall) ? -1. : 1.;
ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE(int i, int j, int) noexcept
{
vel_arr(i,j,-1,0) = mult*vel_arr(i,j,0,0); // u
Expand All @@ -479,7 +475,7 @@ REMORA::FillBdyCCVels (int lev, MultiFab& mf_cc_vel)

// High-z side
if (bx.bigEnd(2) >= domain.bigEnd(2)) {
Real mult = (phys_bc_type[5] == REMORA_BC::no_slip_wall) ? -1. : 1.;
Real mult = (phys_bc_type[BCVars::zvel_bc][5] == REMORA_BC::no_slip_wall) ? -1. : 1.;
ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE(int i, int j, int) noexcept
{
vel_arr(i,j,khi+1,0) = mult*vel_arr(i,j,khi,0); // u
Expand Down
8 changes: 4 additions & 4 deletions Source/IO/Checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ REMORA::WriteCheckpointFile ()
// should be necessary and could instead be replaced by a FillPatch in a more natural
// location
for (int lev = 0; lev <= finest_level; ++lev) {
FillPatch(lev, t_new[lev], *cons_new[lev], cons_new, BdyVars::t,0,true,false);
FillPatch(lev, t_new[lev], *xvel_new[lev], xvel_new, BdyVars::u,0,true,false);
FillPatch(lev, t_new[lev], *yvel_new[lev], yvel_new, BdyVars::v,0,true,false);
FillPatch(lev, t_new[lev], *zvel_new[lev], zvel_new, BdyVars::null,0,true,false);
FillPatch(lev, t_new[lev], *cons_new[lev], cons_new, BCVars::cons_bc, BdyVars::t, 0,true,false);
FillPatch(lev, t_new[lev], *xvel_new[lev], xvel_new, BCVars::xvel_bc, BdyVars::u, 0,true,false);
FillPatch(lev, t_new[lev], *yvel_new[lev], yvel_new, BCVars::yvel_bc, BdyVars::v, 0,true,false);
FillPatch(lev, t_new[lev], *zvel_new[lev], zvel_new, BCVars::zvel_bc, BdyVars::null,0,true,false);
}

// chk00010 write a checkpoint file with this root directory
Expand Down
13 changes: 11 additions & 2 deletions Source/IndexDefines.H
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ namespace BCVars {
xvel_bc = NCONS,
yvel_bc,
zvel_bc,
ubar_bc,
vbar_bc,
zeta_bc,
tke_bc,
foextrap_bc,
NumTypes
};
Expand All @@ -44,7 +48,8 @@ namespace BdyVars {
}

enum struct REMORA_BC {
symmetry, inflow, outflow, no_slip_wall, slip_wall, periodic, undefined
symmetry, inflow, outflow, no_slip_wall, slip_wall, periodic,
clamped, chapman, flather, orlanski_rad, undefined
};

// NOTE: the first of these must match up with the BCType enum
Expand All @@ -56,7 +61,11 @@ enum mathematicalBndryTypes : int { bogus = -666,
int_dir = 0,
reflect_even = 1,
foextrap = 2,
ext_dir = 3
ext_dir = 3,
clamped = 4,
chapman = 5,
flather = 6,
orlanski_rad = 7
};
}
#endif
Loading

0 comments on commit 8732fa2

Please sign in to comment.