Skip to content

Commit

Permalink
Appears to work for 3D with multiple boxes. Needs cgilet hydro
Browse files Browse the repository at this point in the history
e39e4f5
  • Loading branch information
cgilet committed Feb 12, 2024
1 parent 822cf52 commit e3f9635
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 14 deletions.
11 changes: 6 additions & 5 deletions src/boundary_conditions/incflo_set_bcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ incflo::make_nodalBC_mask(int lev)
Box bhi = mfi.validbox() & dhi;
Array4<int> const& mask_arr = new_mask.array(mfi);
if (blo.ok()) {
prob_set_BC_MF(olo, blo, mask_arr, lev, outflow);
prob_set_BC_MF(olo, blo, mask_arr, lev, outflow, "velocity");
}
if (bhi.ok()) {
prob_set_BC_MF(ohi, bhi, mask_arr, lev, outflow);
prob_set_BC_MF(ohi, bhi, mask_arr, lev, outflow, "velocity");
}
}
}
Expand All @@ -82,7 +82,8 @@ incflo::make_nodalBC_mask(int lev)
}

std::unique_ptr<iMultiFab>
incflo::make_BC_MF(int lev, amrex::Gpu::DeviceVector<amrex::BCRec> bcs) //, int scomp, int ncomp)
incflo::make_BC_MF(int lev, amrex::Gpu::DeviceVector<amrex::BCRec> bcs,
std::string field)
{
int ncomp = bcs.size();
// BC info stored in ghost cells to avoid any ambiguity
Expand All @@ -107,7 +108,7 @@ incflo::make_BC_MF(int lev, amrex::Gpu::DeviceVector<amrex::BCRec> bcs) //, int
Box bhi = mfi.growntilebox() & dhi;
Array4<int> const& mask_arr = BC_MF->array(mfi);
if (m_bc_type[olo] == BC::mixed) {
prob_set_BC_MF(olo, blo, mask_arr, lev, outflow);
prob_set_BC_MF(olo, blo, mask_arr, lev, outflow, field);
} else {
amrex::ParallelFor(blo, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
Expand All @@ -117,7 +118,7 @@ incflo::make_BC_MF(int lev, amrex::Gpu::DeviceVector<amrex::BCRec> bcs) //, int
});
}
if (m_bc_type[ohi] == BC::mixed) {
prob_set_BC_MF(ohi, bhi, mask_arr, lev, outflow);
prob_set_BC_MF(ohi, bhi, mask_arr, lev, outflow, field);
} else {
amrex::ParallelFor(bhi, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
Expand Down
8 changes: 6 additions & 2 deletions src/convection/incflo_compute_MAC_projected_velocities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,12 @@ incflo::compute_MAC_projected_velocities (
//
std::unique_ptr<iMultiFab> BC_MF;
if (m_has_mixedBC) {
BC_MF = make_BC_MF(lev, m_bcrec_velocity_d);
BC_MF = make_BC_MF(lev, m_bcrec_velocity_d, "velocity");
}
//fixme
VisMF::Write(*vel[0],"vin");
amrex::Write(*BC_MF,"bcmf");
//

// Predict normal velocity to faces -- note that the {u_mac, v_mac, w_mac}
// returned from this call are on face CENTROIDS
Expand All @@ -252,7 +256,7 @@ incflo::compute_MAC_projected_velocities (
l_advection_type, PPM::default_limiter, BC_MF.get());
}

//fixmeamrex::
//fixme
VisMF::Write(*u_mac[0],"umac");
VisMF::Write(*v_mac[0],"vmac");
//
Expand Down
6 changes: 3 additions & 3 deletions src/convection/incflo_compute_advection_term.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,16 @@ incflo::compute_convective_term (Vector<MultiFab*> const& conv_u,
// FIXME -- would it be worth it to save this from vel extrap???
std::unique_ptr<iMultiFab> velBC_MF;
if (m_has_mixedBC) {
velBC_MF = make_BC_MF(lev, m_bcrec_velocity_d);
velBC_MF = make_BC_MF(lev, m_bcrec_velocity_d, "velocity");
}
std::unique_ptr<iMultiFab> densBC_MF;
if (m_has_mixedBC) {
densBC_MF = make_BC_MF(lev, m_bcrec_density_d);
densBC_MF = make_BC_MF(lev, m_bcrec_density_d, "density");
}
std::unique_ptr<iMultiFab> tracBC_MF;
if (m_advect_tracer && (m_ntrac>0)) {
if (m_has_mixedBC) {
tracBC_MF = make_BC_MF(lev, m_bcrec_tracer_d);
tracBC_MF = make_BC_MF(lev, m_bcrec_tracer_d, "tracer");
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/incflo.H
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ public:
//
///////////////////////////////////////////////////////////////////////////

std::unique_ptr<amrex::iMultiFab> make_BC_MF (int lev, amrex::Gpu::DeviceVector<amrex::BCRec> bcs);
std::unique_ptr<amrex::iMultiFab> make_BC_MF (int lev,
amrex::Gpu::DeviceVector<amrex::BCRec> bcs,
std::string field);
amrex::iMultiFab make_nodalBC_mask (int lev);
// void make_ccBC_mask (int lev, const amrex::BoxArray& ba,
// const amrex::DistributionMapping& dm);
Expand Down Expand Up @@ -219,7 +221,7 @@ public:
void prob_init_fluid (int lev);
void prob_set_BC_MF (amrex::Orientation ori, amrex::Box const& bx,
amrex::Array4<int> const& mask, int lev,
int outflow_val);
int outflow_val, std::string field);
void prob_set_MAC_robinBCs (amrex::Orientation ori, amrex::Box const& bx,
amrex::Array4<amrex::Real> const& robin_a,
amrex::Array4<amrex::Real> const& robin_b,
Expand Down
7 changes: 5 additions & 2 deletions src/prob/prob_bc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
using namespace amrex;

// This function is used to prepare both the nodal projection and advection for
// mixed BCs (i.e. position dependent BCs). The necessarily value to indicate an
// mixed BCs (i.e. position dependent BCs). The necessary value to indicate an
// outflow BC differs between advection and the NodalProj, so we pass it in
void incflo::prob_set_BC_MF (Orientation ori, Box const& bx,
Array4<int> const& mask, int lev,
int outflow_val)
int outflow_val, std::string field)
{
if (1100 == m_probtype || 1101 == m_probtype || 1102 == m_probtype)
{
Expand All @@ -21,6 +21,9 @@ void incflo::prob_set_BC_MF (Orientation ori, Box const& bx,
Box const& domain = geom[lev].Domain();
int half_num_cells = domain.length(direction) / 2;

// for this problem, bcs are same for all fields, only ncomp varies
int ncomp = field == "velocity" ? AMREX_SPACEDIM : 1;

Orientation::Side side = ori.faceDir();
if (side == Orientation::low) {
amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
Expand Down
99 changes: 99 additions & 0 deletions test_3d/inputs.split
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
amrex.fpe_trap_invalid = 1

#¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨#
# SIMULATION STOP #
#.......................................#
max_step = 1 # Max number of time steps
steady_state = 0 # Steady-state solver?

#¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨#
# TIME STEP COMPUTATION #
#.......................................#
incflo.fixed_dt = -1.e-5 # Use this constant dt if > 0
incflo.cfl = 0.45

incflo.do_initial_proj = 1
incflo.initial_iterations = 0

#¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨#
# INPUT AND OUTPUT #
#.......................................#
amr.plot_int = 1 # Steps between plot files
amr.plt_regtest = 1

#¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨#
# PHYSICS #
#.......................................#
incflo.gravity = 0. 0. 0. # Gravitational force (3D)
incflo.ro_0 = 1. # Reference density

incflo.fluid_model = "newtonian" # Fluid model (rheology)
incflo.mu = 0.00 # Dynamic viscosity coefficient
incflo.constant_density = true #

incflo.advection_type = "Godunov"
incflo.diffusion_type = 0
incflo.redistribution_type = "StateRedist"


#¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨#
# ADAPTIVE MESH REFINEMENT #
#.......................................#
amr.n_cell = 64 32 32 # Grid cells at coarsest AMRlevel
amr.max_level = 0 # Max AMR level in hierarchy
amr.max_grid_size_x = 1024
amr.max_grid_size_y = 1024
amr.max_grid_size_z = 1024
#amr.blocking_factor = 8

#¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨#
# GEOMETRY #
#.......................................#
geometry.prob_lo = -2. -1. -1. # Lo corner coordinates
geometry.prob_hi = 2. 1. 1. # Hi corner coordinates
geometry.is_periodic = 0 0 0 # Periodicity x y z (0/1)

# Boundary conditionse39e4f5
xlo.type = "mixed"
xlo.velocity = 1.0 0.0 0.0
xlo.pressure = 0.0

xhi.type = "mixed"
xhi.velocity = 1.0 0.0 0.0
xhi.pressure = 0.0

ylo.type = "nsw"
yhi.type = "nsw"

zlo.type = "nsw"
zhi.type = "nsw"

# Add box
incflo.geometry = "box"
box.internal_flow = false

box.Lo = -2.1 -0.10 -1.1
box.Hi = 2.10 0.10 1.1

#¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨#
# INITIAL CONDITIONS #
#.......................................#
incflo.probtype = 1101

incflo.ic_u = 1.0 #
incflo.ic_v = 0.0 #
incflo.ic_w = 0.0 #
incflo.ic_p = 0.0 #

#¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨#
# VERBOSITY #
#.......................................#
incflo.verbose = 1 # incflo itself
mac_proj.verbose = 1 # MAC Projector
nodal_proj.verbose = 1 # Nodal Projector


#.......................................#
# EB FLOW #
#.......................................#
eb_flow.vel_mag = 0.0

0 comments on commit e3f9635

Please sign in to comment.