Skip to content

Commit

Permalink
use same logic for slip wall as for no-slip wall wrt rho_read (#2055)
Browse files Browse the repository at this point in the history
* use same logic for slip wall as for no-slip wall wrt rho_read

* Add FLowInABox to the ctests

* remove unused
  • Loading branch information
asalmgren authored Jan 10, 2025
1 parent f877a35 commit a2dc25a
Show file tree
Hide file tree
Showing 11 changed files with 27,801 additions and 22 deletions.
7 changes: 7 additions & 0 deletions Exec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ elseif (ERF_ENABLE_REGRESSION_TESTS_ONLY)
add_subdirectory(DryRegTests/ScalarAdvDiff)
add_subdirectory(DryRegTests/TaylorGreenVortex)
add_subdirectory(DryRegTests/TurbulentInflow)
add_subdirectory(DevTests/FlowInABox)
add_subdirectory(DevTests/LandSurfaceModel)
add_subdirectory(DevTests/MetGrid)
add_subdirectory(DevTests/MovingTerrain)
add_subdirectory(DevTests/Radiation)
add_subdirectory(DevTests/TemperatureSource)
add_subdirectory(DevTests/TropicalCyclone)
else ()
add_subdirectory(ABL)
add_subdirectory(MoistRegTests/Bomex)
Expand All @@ -32,6 +38,7 @@ else ()
add_subdirectory(DryRegTests/TurbulentInflow)
add_subdirectory(DryRegTests/WitchOfAgnesi)
add_subdirectory(DryRegTests/WPS_Test)
add_subdirectory(DevTests/FlowInABox)
add_subdirectory(DevTests/LandSurfaceModel)
add_subdirectory(DevTests/MetGrid)
add_subdirectory(DevTests/MovingTerrain)
Expand Down
30 changes: 15 additions & 15 deletions Exec/DevTests/FlowInABox/ERF_Prob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ Problem::Problem(const amrex::Real* problo, const amrex::Real* probhi)
parms.ufac = parms.pert_deltaU * std::exp(0.5) / parms.pert_ref_height;
parms.vfac = parms.pert_deltaV * std::exp(0.5) / parms.pert_ref_height;

Real p_0 = 1.e5;
Real R_d = 287.0;
Real c_p = 1004.5;
Real rdOcp = R_d / c_p;
Real prob_p_0 = 1.e5;
Real prob_R_d = 287.0;
Real prob_c_p = 1004.5;
Real prob_rdOcp = prob_R_d / prob_c_p;

// Read in T_0 as temperature not theta then convert to theta
Real th_0 = getThgivenPandT(parms.T_0, p_0, rdOcp);
Real r_0 = p_0 / (R_d * parms.T_0);
Real prob_th_0 = getThgivenPandT(parms.T_0, prob_p_0, prob_rdOcp);
Real prob_r_0 = prob_p_0 / (prob_R_d * parms.T_0);

amrex::Print() << "READING IN T0 as " << parms.T_0 << std::endl;
amrex::Print() << "COMPUTING THETA to be " << th_0 << std::endl;
amrex::Print() << "COMPUTING THETA to be " << prob_th_0 << std::endl;

init_base_parms(r_0, th_0);
init_base_parms(prob_r_0, prob_th_0);
}

void
Expand All @@ -67,13 +67,13 @@ Problem::init_custom_pert(
amrex::Array4<amrex::Real > const& z_vel_pert,
amrex::Array4<amrex::Real > const& r_hse,
amrex::Array4<amrex::Real > const& /*p_hse*/,
amrex::Array4<amrex::Real const> const& z_nd,
amrex::Array4<amrex::Real const> const& z_cc,
amrex::GeometryData const& geomdata,
amrex::Array4<amrex::Real const> const& /*z_nd*/,
amrex::Array4<amrex::Real const> const& /*z_cc*/,
amrex::GeometryData const& /*geomdata*/,
amrex::Array4<amrex::Real const> const& /*mf_m*/,
amrex::Array4<amrex::Real const> const& /*mf_u*/,
amrex::Array4<amrex::Real const> const& /*mf_v*/,
const SolverChoice& sc)
const SolverChoice& /*sc*/)
{

// Add temperature perturbations
Expand All @@ -86,15 +86,15 @@ Problem::init_custom_pert(
});

// Set the x-velocity
ParallelFor(xbx, [=, parms_d=parms] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
ParallelFor(xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
x_vel_pert(i, j, k) = 0.0;
});
// Set the y-velocity
ParallelFor(ybx, [=, parms_d=parms] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
ParallelFor(ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
y_vel_pert(i, j, k) = 0.0;
});
// Set the z-velocity
ParallelFor(zbx, [=, parms_d=parms] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
ParallelFor(zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
z_vel_pert(i, j, k) = 0.0;
});
}
8 changes: 4 additions & 4 deletions Source/EB/ERF_Redistribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ERF::redistribute_term ( int lev,
MultiFab& result_tmp, // Saves doing a MF::copy. does this matter???
MultiFab const& state,
BCRec const* bc, // this is bc for the state (needed for SRD slopes)
Real const dt)
Real const local_dt)
{
// ************************************************************************
// Redistribute result_tmp and pass out result
Expand All @@ -25,7 +25,7 @@ ERF::redistribute_term ( int lev,
#endif
for (MFIter mfi(state,TilingIfNotGPU()); mfi.isValid(); ++mfi)
{
redistribute_term(mfi, lev, result, result_tmp, state, bc, dt);
redistribute_term(mfi, lev, result, result_tmp, state, bc, local_dt);
}
}

Expand All @@ -35,7 +35,7 @@ ERF::redistribute_term ( MFIter const& mfi, int lev,
MultiFab& result_tmp,
MultiFab const& state,
BCRec const* bc, // this is bc for the state (needed for SRD slopes)
Real const dt)
Real const local_dt)
{
AMREX_ASSERT(result.nComp() == state.nComp());

Expand Down Expand Up @@ -85,7 +85,7 @@ ERF::redistribute_term ( MFIter const& mfi, int lev,
scratch, flag,
apx, apy, apz, vfrac,
fcx, fcy, fcz, ccc,
bc, geom[lev], dt, redistribution_type);
bc, geom[lev], local_dt, redistribution_type);
}
else
{
Expand Down
7 changes: 5 additions & 2 deletions Source/ERF_Tagging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ ERF::ErrorEst (int levc, TagBoxArray& tags, Real time, int /*ngrow*/)

for (int j=0; j < ref_tags.size(); ++j)
{
std::unique_ptr<MultiFab> mf = std::make_unique<MultiFab>(grids[levc], dmap[levc], 1, 0);
//
// This mf must have ghost cells because we may take differences between adjacent values
//
std::unique_ptr<MultiFab> mf = std::make_unique<MultiFab>(grids[levc], dmap[levc], 1, 1);

// This allows dynamic refinement based on the value of the density
if (ref_tags[j].Field() == "density")
Expand All @@ -45,7 +48,7 @@ ERF::ErrorEst (int levc, TagBoxArray& tags, Real time, int /*ngrow*/)
{
for (MFIter mfi(*mf, TilingIfNotGPU()); mfi.isValid(); ++mfi)
{
const Box& bx = mfi.tilebox();
const Box& bx = mfi.growntilebox();
auto& dfab = (*mf)[mfi];
auto& sfab = vars_new[levc][Vars::cons][mfi];
if (ref_tags[j].Field() == "scalar") {
Expand Down
3 changes: 2 additions & 1 deletion Source/Initialization/ERF_InitBCs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ void ERF::init_bcs ()
domain_bc_type[ori] = "SlipWall";

Real rho_in;
if (pp.query("density", rho_in))
rho_read = pp.query("density", rho_in);
if (rho_read)
{
m_bc_extdir_vals[BCVars::Rho_bc_comp][ori] = rho_in;
}
Expand Down
1 change: 1 addition & 0 deletions Tests/CTestList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ add_test_r(DensityCurrent_detJ2 "DryRegTests/DensityCurrent" "erf_d
add_test_r(DensityCurrent_detJ2_nosub "DryRegTests/DensityCurrent" "erf_density_current" "plt00020")
add_test_r(DensityCurrent_detJ2_MT "DryRegTests/DensityCurrent" "erf_density_current" "plt00010")
add_test_r(EkmanSpiral "DryRegTests/EkmanSpiral" "erf_ekman_spiral" "plt00010")
add_test_r(FlowInABox "DevTests/FlowInABox" "erf_flow_in_a_box" "plt00010")
add_test_r(IsentropicVortexStationary "DryRegTests/IsentropicVortex" "erf_isentropic_vortex" "plt00010")
add_test_r(IsentropicVortexAdvecting "DryRegTests/IsentropicVortex" "erf_isentropic_vortex" "plt00010")
add_test_r(IVA_NumDiff "DryRegTests/IsentropicVortex" "erf_isentropic_vortex" "plt00010")
Expand Down
29 changes: 29 additions & 0 deletions Tests/ERFGoldFiles/FlowInABox/Header
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
HyperCLaw-V1.1
7
density
x_velocity
y_velocity
z_velocity
temp
theta
pressure
3
0.24999999999999997
0
-1 -1 0
1 1 1

((0,0,0) (63,63,31) (0,0,0))
10
0.03125 0.03125 0.03125
0
0
0 2 0.24999999999999997
10
-1 1
-1 0
0 1
-1 1
0 1
0 1
Level_0/Cell
13,763 changes: 13,763 additions & 0 deletions Tests/ERFGoldFiles/FlowInABox/Level_0/Cell_D_00000

Large diffs are not rendered by default.

13,878 changes: 13,878 additions & 0 deletions Tests/ERFGoldFiles/FlowInABox/Level_0/Cell_D_00001

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions Tests/ERFGoldFiles/FlowInABox/Level_0/Cell_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
1
1
7
0
(2 0
((0,0,0) (63,31,31) (0,0,0))
((0,32,0) (63,63,31) (0,0,0))
)
2
FabOnDisk: Cell_D_00000 0
FabOnDisk: Cell_D_00001 0

2,7
1.22256861666361027e+00,-1.25124273910836724e-04,-1.29031227767734027e-04,-4.27282127127780490e-04,2.84884360193858925e+02,2.84917395349752155e+02,9.99903432812499523e+04,
1.22256861666361027e+00,-1.15699167123401047e-04,-1.25301919948949021e-04,-4.26715933048073520e-04,2.84883644912524744e+02,2.84916884375084521e+02,9.99903432812499523e+04,

2,7
1.22256861666361027e+00,1.20118015081812729e-04,1.37265105983438356e-04,4.39876062253704648e-04,2.85119969325273473e+02,2.85085687223013736e+02,9.99998467187500064e+04,
1.22256861666361027e+00,1.19765731747955065e-04,1.08569215906653731e-04,4.32763830481513166e-04,2.85120951344551372e+02,2.85086388580670416e+02,9.99998467187500064e+04,

77 changes: 77 additions & 0 deletions Tests/test_files/FlowInABox/FlowInABox.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
max_step = 10

amrex.fpe_trap_invalid = 1

erf.anelastic = 1

erf.init_type = "uniform"

fabarray.mfiter_tile_size = 1024 1024 1024

# PROBLEM SIZE & GEOMETRY
geometry.prob_lo = -1. -1. 0.
geometry.prob_hi = 1. 1. 1.

#coarse
amr.n_cell = 64 64 32

geometry.is_periodic = 0 0 0

xlo.type = "SlipWall"
xhi.type = "SlipWall"
ylo.type = "SlipWall"
yhi.type = "SlipWall"
zlo.type = "SlipWall"
zhi.type = "SlipWall"

xlo.theta = 285.
xhi.theta = 285.
ylo.theta = 285.
yhi.theta = 285.
zlo.theta = 299.
zhi.theta = 280.

xlo.density = 1.2225686
xhi.density = 1.2225686
ylo.density = 1.2225686
yhi.density = 1.2225686
zlo.density = 1.2225686
zhi.density = 1.2225686

# TIME STEP CONTROL
#erf.cfl = 0.9
erf.fixed_dt = 0.025

# DIAGNOSTICS & VERBOSITY
erf.sum_interval = 1 # timesteps between computing mass
erf.v = 1 # verbosity in ERF.cpp
amr.v = 1 # verbosity in Amr.cpp

# REFINEMENT / REGRIDDING
amr.max_level = 0 # maximum level number allowed

# CHECKPOINT FILES
erf.check_file = chk # root name of checkpoint file
erf.check_int = 1000 # number of timesteps between checkpoints

# PLOTFILES
erf.plot_file_1 = plt # prefix of plotfile name
erf.plot_int_1 = 100 # number of timesteps between plotfiles
erf.plot_vars_1 = density x_velocity y_velocity z_velocity pressure temp theta

erf.use_gravity = true

# SOLVER CHOICE
erf.molec_diff_type = "None"
erf.alpha_T = 0.0
erf.alpha_C = 0.0

erf.les_type = "Smagorinsky"
erf.Cs = 0.1
erf.Pr_t = 0.33333333333333

# PROBLEM PARAMETERS
prob.rho_0 = 1.0
prob.T_0 = 285.
prob.T_0_Pert_Mag = 0.1

0 comments on commit a2dc25a

Please sign in to comment.