Skip to content

Commit

Permalink
Merge branch 'AMReX-Fluids:development' into vof
Browse files Browse the repository at this point in the history
  • Loading branch information
IFDL-WSU authored Sep 6, 2024
2 parents 6c9cba0 + 3db46ad commit 16811b2
Show file tree
Hide file tree
Showing 14 changed files with 640 additions and 176 deletions.
40 changes: 20 additions & 20 deletions src/boundary_conditions/README.org
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
* fillpatch

| | pi | po | mi | nsw | sw |
|--------+----------+----------+----------+-------------+---------------------------------------|
| v_n | foextrap | foextrap | ext_dir | ext_dir (0) | ext_dir (0) |
| v_t | foextrap | foextrap | ext_dir | ext_dir (0) | hoextrap |
| rho | foextrap | foextrap | ext_dir | foextrap | if (advection_type == "BDS") foextrap |
| | | | | | else hoextrap |
| scalar | foextrap | foextrap | ext_dir | foextrap | if (advection_type == "BDS") foextrap |
| | | | | | else hoextrap |
| force | foextrap | foextrap | foextrap | foextrap | foextrap |
| | pi | po | mi | nsw | sw | dir_dep |
|--------+----------+----------+----------+-------------+---------------------------------------|-----------------------
| v_n | foextrap | foextrap | ext_dir | ext_dir (0) | ext_dir (0) | ext_dir if inflowing |
| v_t | foextrap | foextrap | ext_dir | ext_dir (0) | hoextrap | ext_dir if inflowing |
| rho | foextrap | foextrap | ext_dir | foextrap | if (advection_type == "BDS") foextrap | ext_dir if inflowing |
| | | | | | else hoextrap | ext_dir if inflowing |
| scalar | foextrap | foextrap | ext_dir | foextrap | if (advection_type == "BDS") foextrap | ext_dir if inflowing |
| | | | | | else hoextrap | ext_dir if inflowing |
| force | foextrap | foextrap | foextrap | foextrap | foextrap | foextrap |

* projection

| pi | po | mi | nsw | sw |
|-----------+-----------+---------+---------+---------|
| Dirichlet | Dirichlet | Neumann | Neumann | Neumann |
| pi | po | mi | nsw | sw | dir_dep |
|-----------+-----------+---------+---------+---------|----------
| Dirichlet | Dirichlet | Neumann | Neumann | Neumann | Neumann |

* tensor solve

| | pi | po | mi | nsw | sw |
|--------+---------+---------+-----------+---------------+---------------|
| normal | Neumann | Neumann | Dirichlet | Dirichlet (0) | Dirichlet (0) |
| tang | Neumann | Neumann | Dirichlet | Dirichlet (0) | Neumann (0) |
| | pi | po | mi | nsw | sw | dir_dep |
|--------+---------+---------+-----------+---------------+---------------|------------
| normal | Neumann | Neumann | Dirichlet | Dirichlet (0) | Dirichlet (0) | Dirichlet |
| tang | Neumann | Neumann | Dirichlet | Dirichlet (0) | Neumann (0) | Dirichlet |

* scalar diffusion

| pi | po | mi | nsw | sw |
|---------+---------+-----------+---------+---------|
| Neumann | Neumann | Dirichlet | Neumann | Neumann |
| Neumann | Neumann | Dirichlet | Neumann | Neumann |
| pi | po | mi | nsw | sw | dir_dep |
|---------+---------+-----------+---------+---------|------------
| Neumann | Neumann | Dirichlet | Neumann | Neumann | Dirichlet |
| Neumann | Neumann | Dirichlet | Neumann | Neumann | Dirichlet |

48 changes: 48 additions & 0 deletions src/boundary_conditions/boundary_conditions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ using namespace amrex;

void incflo::init_bcs ()
{
has_inout_bndry = false;

auto f = [this] (std::string const& bcid, Orientation ori)
{
m_bc_density[ori] = 1.0;
Expand Down Expand Up @@ -53,6 +55,24 @@ void incflo::init_bcs ()
pp.query("density", m_bc_density[ori]);
pp.queryarr("tracer", m_bc_tracer[ori], 0, m_ntrac);
}
else if (bc_type == "direction_dependent" || bc_type == "dd" )
{
amrex::Print() << bcid << " set to direction-dependent.\n";

has_inout_bndry = true;

m_bc_type[ori] = BC::direction_dependent;

std::vector<Real> v;
if (pp.queryarr("velocity", v, 0, AMREX_SPACEDIM)) {
for (int i=0; i<AMREX_SPACEDIM; i++){
m_bc_velocity[ori][i] = v[i];
}
}

pp.query("density", m_bc_density[ori]);
pp.queryarr("tracer", m_bc_tracer[ori], 0, m_ntrac);
}
else if (bc_type == "no_slip_wall" || bc_type == "nsw")
{
amrex::Print() << bcid <<" set to no-slip wall.\n";
Expand Down Expand Up @@ -205,6 +225,18 @@ void incflo::init_bcs ()
m_bcrec_velocity[2].setHi(dir, BCType::ext_dir););
}
}
else if (bct == BC::direction_dependent)
{
if (side == Orientation::low) {
AMREX_D_TERM(m_bcrec_velocity[0].setLo(dir, BCType::direction_dependent);,
m_bcrec_velocity[1].setLo(dir, BCType::direction_dependent);,
m_bcrec_velocity[2].setLo(dir, BCType::direction_dependent););
} else {
AMREX_D_TERM(m_bcrec_velocity[0].setHi(dir, BCType::direction_dependent);,
m_bcrec_velocity[1].setHi(dir, BCType::direction_dependent);,
m_bcrec_velocity[2].setHi(dir, BCType::direction_dependent););
}
}
else if (bct == BC::slip_wall)
{
if (side == Orientation::low) {
Expand Down Expand Up @@ -290,6 +322,14 @@ void incflo::init_bcs ()
m_bcrec_density[0].setHi(dir, BCType::ext_dir);
}
}
else if (bct == BC::direction_dependent)
{
if (side == Orientation::low) {
m_bcrec_density[0].setLo(dir, BCType::direction_dependent);
} else {
m_bcrec_density[0].setHi(dir, BCType::direction_dependent);
}
}
else if (bct == BC::periodic)
{
if (side == Orientation::low) {
Expand Down Expand Up @@ -366,6 +406,14 @@ void incflo::init_bcs ()
for (auto& b : m_bcrec_tracer) b.setHi(dir, BCType::ext_dir);
}
}
else if (bct == BC::direction_dependent)
{
if (side == Orientation::low) {
for (auto& b : m_bcrec_tracer) b.setLo(dir, BCType::direction_dependent);
} else {
for (auto& b : m_bcrec_tracer) b.setHi(dir, BCType::direction_dependent);
}
}
else if (bct == BC::periodic)
{
if (side == Orientation::low) {
Expand Down
20 changes: 10 additions & 10 deletions src/boundary_conditions/incflo_fillpatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void incflo::fillpatch_density (int lev, Real time, MultiFab& density, int ng)
{
if (lev == 0) {
PhysBCFunct<GpuBndryFuncFab<IncfloDenFill> > physbc(geom[lev], get_density_bcrec(),
IncfloDenFill{m_probtype, m_bc_density});
IncfloDenFill{m_probtype, m_bc_density, m_bc_velocity});
FillPatchSingleLevel(density, IntVect(ng), time,
{&(m_leveldata[lev]->density_o),
&(m_leveldata[lev]->density)},
Expand All @@ -56,9 +56,9 @@ void incflo::fillpatch_density (int lev, Real time, MultiFab& density, int ng)
} else {
const auto& bcrec = get_density_bcrec();
PhysBCFunct<GpuBndryFuncFab<IncfloDenFill> > cphysbc
(geom[lev-1], bcrec, IncfloDenFill{m_probtype, m_bc_density});
(geom[lev-1], bcrec, IncfloDenFill{m_probtype, m_bc_density, m_bc_velocity});
PhysBCFunct<GpuBndryFuncFab<IncfloDenFill> > fphysbc
(geom[lev], bcrec, IncfloDenFill{m_probtype, m_bc_density});
(geom[lev], bcrec, IncfloDenFill{m_probtype, m_bc_density, m_bc_velocity});
#ifdef AMREX_USE_EB
Interpolater* mapper = (EBFactory(0).isAllRegular()) ?
(Interpolater*)(&cell_cons_interp) : (Interpolater*)(&eb_cell_cons_interp);
Expand All @@ -83,7 +83,7 @@ void incflo::fillpatch_tracer (int lev, Real time, MultiFab& tracer, int ng)
if (m_ntrac <= 0) return;
if (lev == 0) {
PhysBCFunct<GpuBndryFuncFab<IncfloTracFill> > physbc
(geom[lev], get_tracer_bcrec(), IncfloTracFill{m_probtype, m_ntrac, m_bc_tracer_d});
(geom[lev], get_tracer_bcrec(), IncfloTracFill{m_probtype, m_ntrac, m_bc_tracer_d, m_bc_velocity});
FillPatchSingleLevel(tracer, IntVect(ng), time,
{&(m_leveldata[lev]->tracer_o),
&(m_leveldata[lev]->tracer)},
Expand All @@ -92,9 +92,9 @@ void incflo::fillpatch_tracer (int lev, Real time, MultiFab& tracer, int ng)
} else {
const auto& bcrec = get_tracer_bcrec();
PhysBCFunct<GpuBndryFuncFab<IncfloTracFill> > cphysbc
(geom[lev-1], bcrec, IncfloTracFill{m_probtype, m_ntrac, m_bc_tracer_d});
(geom[lev-1], bcrec, IncfloTracFill{m_probtype, m_ntrac, m_bc_tracer_d, m_bc_velocity});
PhysBCFunct<GpuBndryFuncFab<IncfloTracFill> > fphysbc
(geom[lev], bcrec, IncfloTracFill{m_probtype, m_ntrac, m_bc_tracer_d});
(geom[lev], bcrec, IncfloTracFill{m_probtype, m_ntrac, m_bc_tracer_d, m_bc_velocity});
#ifdef AMREX_USE_EB
Interpolater* mapper = (EBFactory(0).isAllRegular()) ?
(Interpolater*)(&cell_cons_interp) : (Interpolater*)(&eb_cell_cons_interp);
Expand Down Expand Up @@ -196,9 +196,9 @@ void incflo::fillcoarsepatch_density (int lev, Real time, MultiFab& density, int
{
const auto& bcrec = get_density_bcrec();
PhysBCFunct<GpuBndryFuncFab<IncfloDenFill> > cphysbc
(geom[lev-1], bcrec, IncfloDenFill{m_probtype, m_bc_density});
(geom[lev-1], bcrec, IncfloDenFill{m_probtype, m_bc_density, m_bc_velocity});
PhysBCFunct<GpuBndryFuncFab<IncfloDenFill> > fphysbc
(geom[lev], bcrec, IncfloDenFill{m_probtype, m_bc_density});
(geom[lev], bcrec, IncfloDenFill{m_probtype, m_bc_density, m_bc_velocity});
#ifdef AMREX_USE_EB
Interpolater* mapper = (EBFactory(0).isAllRegular()) ?
(Interpolater*)(&cell_cons_interp) : (Interpolater*)(&eb_cell_cons_interp);
Expand All @@ -218,9 +218,9 @@ void incflo::fillcoarsepatch_tracer (int lev, Real time, MultiFab& tracer, int n

const auto& bcrec = get_tracer_bcrec();
PhysBCFunct<GpuBndryFuncFab<IncfloTracFill> > cphysbc
(geom[lev-1], bcrec, IncfloTracFill{m_probtype, m_ntrac, m_bc_tracer_d});
(geom[lev-1], bcrec, IncfloTracFill{m_probtype, m_ntrac, m_bc_tracer_d, m_bc_velocity});
PhysBCFunct<GpuBndryFuncFab<IncfloTracFill> > fphysbc
(geom[lev], bcrec, IncfloTracFill{m_probtype, m_ntrac, m_bc_tracer_d});
(geom[lev], bcrec, IncfloTracFill{m_probtype, m_ntrac, m_bc_tracer_d, m_bc_velocity});
#ifdef AMREX_USE_EB
Interpolater* mapper = (EBFactory(0).isAllRegular()) ?
(Interpolater*)(&cell_cons_interp) : (Interpolater*)(&eb_cell_cons_interp);
Expand Down
7 changes: 4 additions & 3 deletions src/boundary_conditions/incflo_fillphysbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ void incflo::fillphysbc_velocity (int lev, Real time, MultiFab& vel, int ng)

void incflo::fillphysbc_density (int lev, Real time, MultiFab& density, int ng)
{
PhysBCFunct<GpuBndryFuncFab<IncfloDenFill> > physbc(geom[lev], get_density_bcrec(),
IncfloDenFill{m_probtype, m_bc_density});
PhysBCFunct<GpuBndryFuncFab<IncfloDenFill> > physbc(geom[lev],
get_density_bcrec(),
IncfloDenFill{m_probtype, m_bc_density, m_bc_velocity});
physbc.FillBoundary(density, 0, 1, IntVect(ng), time, 0);
}

void incflo::fillphysbc_tracer (int lev, Real time, MultiFab& tracer, int ng)
{
if (m_ntrac > 0) {
PhysBCFunct<GpuBndryFuncFab<IncfloTracFill> > physbc
(geom[lev], get_tracer_bcrec(), IncfloTracFill{m_probtype, m_ntrac, m_bc_tracer_d});
(geom[lev], get_tracer_bcrec(), IncfloTracFill{m_probtype, m_ntrac, m_bc_tracer_d, m_bc_velocity});
physbc.FillBoundary(tracer, 0, m_ntrac, IntVect(ng), time, 0);
}
}
24 changes: 18 additions & 6 deletions src/convection/incflo_compute_MAC_projected_velocities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,12 @@ incflo::compute_MAC_projected_velocities (
{
int n = 0;
const auto bc = HydroBC::getBC(i, j, k, n, domain, bc_vel_d, velbc_arr);
if (i == dlo.x && bc.lo(0) == BCType::ext_dir) {
if (i == dlo.x && ( bc.lo(0) == BCType::ext_dir ||
(bc.lo(0) == BCType::direction_dependent && cc_arr(i-1,j,k,0) >= Real(0.0)) ) ) {
umac_arr(i,j,k) = cc_arr(i-1,j,k,0);
}
if (i == dhi.x && bc.hi(0) == BCType::ext_dir) {
if (i == dhi.x && ( bc.hi(0) == BCType::ext_dir ||
(bc.hi(0) == BCType::direction_dependent && cc_arr(i+1,j,k,0) <= Real(0.0)) ) ) {
umac_arr(i+1,j,k) = cc_arr(i+1,j,k,0);
}
});
Expand All @@ -238,10 +240,12 @@ incflo::compute_MAC_projected_velocities (
{
int n = 1;
const auto bc = HydroBC::getBC(i, j, k, n, domain, bc_vel_d, velbc_arr);
if (j == dlo.y && bc.lo(1) == BCType::ext_dir) {
if (j == dlo.y && ( bc.lo(1) == BCType::ext_dir||
(bc.lo(1) == BCType::direction_dependent && cc_arr(i,j-1,k,1) >= Real(0.0)) ) ) {
vmac_arr(i,j,k) = cc_arr(i,j-1,k,1);
}
if (j == dhi.y && bc.hi(1) == BCType::ext_dir) {
if (j == dhi.y && ( bc.hi(1) == BCType::ext_dir ||
(bc.hi(1) == BCType::direction_dependent && cc_arr(i,j+1,k,1) <= Real(0.0)) ) ) {
vmac_arr(i,j+1,k) = cc_arr(i,j+1,k,1);
}
});
Expand All @@ -251,17 +255,25 @@ incflo::compute_MAC_projected_velocities (
{
int n = 2;
const auto bc = HydroBC::getBC(i, j, k, n, domain, bc_vel_d, velbc_arr);
if (k == dlo.z && bc.lo(2) == BCType::ext_dir) {
if (k == dlo.z && ( bc.lo(2) == BCType::ext_dir ||
(bc.lo(2) == BCType::direction_dependent && cc_arr(1,j,k-1,2) >= Real(0.0)) ) ) {
wmac_arr(i,j,k) = cc_arr(i,j,k-1,2);
}
if (k == dhi.z && bc.hi(2) == BCType::ext_dir) {
if (k == dhi.z && ( bc.hi(2) == BCType::ext_dir ||
(bc.hi(2) == BCType::direction_dependent && cc_arr(i,j,k+1,2) <= Real(0.0)) ) ) {
wmac_arr(i,j,k+1) = cc_arr(i,j,k+1,2);
}
});
#endif
} // mfi
} // lev

// Enforce solvability by matching outflow to inflow.
if (has_inout_bndry)
{
HydroUtils::enforceInOutSolvability(mac_vec, get_velocity_bcrec().data(), geom);
}

macproj->setUMAC(mac_vec);

#ifdef AMREX_USE_EB
Expand Down
3 changes: 3 additions & 0 deletions src/diffusion/incflo_diffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ incflo::get_diffuse_tensor_bc (Orientation::Side side) const noexcept
break;
}
case BC::mass_inflow:
case BC::direction_dependent:
case BC::no_slip_wall:
{
// All three components are Dirichlet
Expand Down Expand Up @@ -174,6 +175,7 @@ incflo::get_diffuse_velocity_bc (Orientation::Side side, int comp) const noexcep
break;
}
case BC::mass_inflow:
case BC::direction_dependent:
case BC::no_slip_wall:
{
// All three components are Dirichlet
Expand Down Expand Up @@ -239,6 +241,7 @@ incflo::get_diffuse_scalar_bc (Orientation::Side side) const noexcept
break;
}
case BC::mass_inflow:
case BC::direction_dependent:
{
r[dir] = LinOpBCType::Dirichlet;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/embedded_boundaries/eb_cylinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void incflo::make_eb_cylinder()
amrex::Print() << " Direction: " << direction << std::endl;
amrex::Print() << " Rotation angle(rad): " << rotation << std::endl;
amrex::Print() << " Rotation axe: " << rotation_axe << std::endl;
#if (AMREX_SPACDEIM == 3)
#if (AMREX_SPACEDIM == 3)
amrex::Print() << " Center: " << center[0] << ", " << center[1] << ", " << center[2]
<< std::endl;
#else
Expand Down
3 changes: 2 additions & 1 deletion src/incflo.H
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ private:

enum struct BC {
pressure_inflow, pressure_outflow, mass_inflow, no_slip_wall, slip_wall,
periodic, mixed, undefined
periodic, mixed, direction_dependent, undefined
};

bool m_has_mixedBC = false;
Expand Down Expand Up @@ -899,6 +899,7 @@ private:
///////////////////////////////////////////////////////////////////////////

void init_bcs ();
bool has_inout_bndry;

///////////////////////////////////////////////////////////////////////////
//
Expand Down
Loading

0 comments on commit 16811b2

Please sign in to comment.