Skip to content

Commit

Permalink
merge with development
Browse files Browse the repository at this point in the history
  • Loading branch information
asalmgren committed Jan 10, 2025
2 parents e0d49c7 + a2dc25a commit 542d1fc
Show file tree
Hide file tree
Showing 13 changed files with 27,911 additions and 137 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;
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ amrex_probinit(const amrex_real* problo, const amrex_real* probhi)
return std::make_unique<Problem>(problo, probhi);
}

Problem::Problem(const amrex::Real* problo, const amrex::Real* probhi)
Problem::Problem(const Real* problo, const Real* probhi)
{
// Parse params
ParmParse pp("prob");
Expand Down Expand Up @@ -41,28 +41,28 @@ Problem::Problem(const amrex::Real* problo, const amrex::Real* probhi)

void
Problem::init_custom_pert(
const amrex::Box& bx,
const amrex::Box& xbx,
const amrex::Box& ybx,
const amrex::Box& zbx,
amrex::Array4<amrex::Real const> const& /*state*/,
amrex::Array4<amrex::Real > const& state_pert,
amrex::Array4<amrex::Real > const& x_vel_pert,
amrex::Array4<amrex::Real > const& y_vel_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& /*mf_m*/,
amrex::Array4<amrex::Real const> const& /*mf_u*/,
amrex::Array4<amrex::Real const> const& /*mf_v*/,
const Box& bx,
const Box& xbx,
const Box& ybx,
const Box& zbx,
Array4<Real const> const& /*state*/,
Array4<Real > const& state_pert,
Array4<Real > const& x_vel_pert,
Array4<Real > const& y_vel_pert,
Array4<Real > const& z_vel_pert,
Array4<Real > const& /*r_hse*/,
Array4<Real > const& /*p_hse*/,
Array4<Real const> const& /*z_nd*/,
Array4<Real const> const& /*z_cc*/,
GeometryData const& geomdata,
Array4<Real const> const& /*mf_m*/,
Array4<Real const> const& /*mf_u*/,
Array4<Real const> const& /*mf_v*/,
const SolverChoice& sc)
{
const bool use_moisture = (sc.moisture_type != MoistureType::None);

ParallelForRNG(bx, [=, parms_d=parms] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine& engine) noexcept {
ParallelForRNG(bx, [=, parms_d=parms] AMREX_GPU_DEVICE(int i, int j, int k, const RandomEngine& engine) noexcept {
// Geometry
const Real* prob_lo = geomdata.ProbLo();
const Real* prob_hi = geomdata.ProbHi();
Expand All @@ -80,7 +80,7 @@ Problem::init_custom_pert(

// Add temperature perturbations
if ((z <= parms_d.pert_ref_height) && (parms_d.T_0_Pert_Mag != 0.0)) {
Real rand_double = amrex::Random(engine); // Between 0.0 and 1.0
Real rand_double = Random(engine); // Between 0.0 and 1.0
state_pert(i, j, k, RhoTheta_comp) = (rand_double*2.0 - 1.0)*parms_d.T_0_Pert_Mag;
}

Expand All @@ -97,7 +97,7 @@ Problem::init_custom_pert(
});

// Set the x-velocity
ParallelForRNG(xbx, [=, parms_d=parms] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine& engine) noexcept {
ParallelForRNG(xbx, [=, parms_d=parms] AMREX_GPU_DEVICE(int i, int j, int k, const RandomEngine& engine) noexcept {
const Real* prob_lo = geomdata.ProbLo();
const Real* dx = geomdata.CellSize();
const Real y = prob_lo[1] + (j + 0.5) * dx[1];
Expand All @@ -107,21 +107,21 @@ Problem::init_custom_pert(
x_vel_pert(i, j, k) = parms_d.U_0;
if ((z <= parms_d.pert_ref_height) && (parms_d.U_0_Pert_Mag != 0.0))
{
Real rand_double = amrex::Random(engine); // Between 0.0 and 1.0
Real rand_double = Random(engine); // Between 0.0 and 1.0
Real x_vel_prime = (rand_double*2.0 - 1.0)*parms_d.U_0_Pert_Mag;
x_vel_pert(i, j, k) += x_vel_prime;
}
if (parms_d.pert_deltaU != 0.0)
{
const amrex::Real yl = y - prob_lo[1];
const amrex::Real zl = z / parms_d.pert_ref_height;
const amrex::Real damp = std::exp(-0.5 * zl * zl);
const Real yl = y - prob_lo[1];
const Real zl = z / parms_d.pert_ref_height;
const Real damp = std::exp(-0.5 * zl * zl);
x_vel_pert(i, j, k) += parms_d.ufac * damp * z * std::cos(parms_d.aval * yl);
}
});

// Set the y-velocity
ParallelForRNG(ybx, [=, parms_d=parms] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine& engine) noexcept {
ParallelForRNG(ybx, [=, parms_d=parms] AMREX_GPU_DEVICE(int i, int j, int k, const RandomEngine& engine) noexcept {
const Real* prob_lo = geomdata.ProbLo();
const Real* dx = geomdata.CellSize();
const Real x = prob_lo[0] + (i + 0.5) * dx[0];
Expand All @@ -131,21 +131,21 @@ Problem::init_custom_pert(
y_vel_pert(i, j, k) = parms_d.V_0;
if ((z <= parms_d.pert_ref_height) && (parms_d.V_0_Pert_Mag != 0.0))
{
Real rand_double = amrex::Random(engine); // Between 0.0 and 1.0
Real rand_double = Random(engine); // Between 0.0 and 1.0
Real y_vel_prime = (rand_double*2.0 - 1.0)*parms_d.V_0_Pert_Mag;
y_vel_pert(i, j, k) += y_vel_prime;
}
if (parms_d.pert_deltaV != 0.0)
{
const amrex::Real xl = x - prob_lo[0];
const amrex::Real zl = z / parms_d.pert_ref_height;
const amrex::Real damp = std::exp(-0.5 * zl * zl);
const Real xl = x - prob_lo[0];
const Real zl = z / parms_d.pert_ref_height;
const Real damp = std::exp(-0.5 * zl * zl);
y_vel_pert(i, j, k) += parms_d.vfac * damp * z * std::cos(parms_d.bval * xl);
}
});

// Set the z-velocity
ParallelForRNG(zbx, [=, parms_d=parms] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine& engine) noexcept {
ParallelForRNG(zbx, [=, parms_d=parms] AMREX_GPU_DEVICE(int i, int j, int k, const RandomEngine& engine) noexcept {
const int dom_lo_z = geomdata.Domain().smallEnd()[2];
const int dom_hi_z = geomdata.Domain().bigEnd()[2];

Expand All @@ -156,7 +156,7 @@ Problem::init_custom_pert(
}
else if (parms_d.W_0_Pert_Mag != 0.0)
{
Real rand_double = amrex::Random(engine); // Between 0.0 and 1.0
Real rand_double = Random(engine); // Between 0.0 and 1.0
Real z_vel_prime = (rand_double*2.0 - 1.0)*parms_d.W_0_Pert_Mag;
z_vel_pert(i, j, k) = parms_d.W_0 + z_vel_prime;
}
Expand All @@ -174,11 +174,15 @@ Problem::init_custom_terrain (
auto ProbLoArr = geom.ProbLoArray();

// Domain valid box (z_nd is nodal)
const amrex::Box& domain = geom.Domain();
const Box& domain = geom.Domain();
int domlo_x = domain.smallEnd(0); int domhi_x = domain.bigEnd(0) + 1;
int domlo_y = domain.smallEnd(1); int domhi_y = domain.bigEnd(1) + 1;
int domlo_z = domain.smallEnd(2);

// Domain cell size and real bounds
auto dx = geom.CellSizeArray();
auto ProbLoArr = geom.ProbLoArray();

// User function parameters
Real xcen = 500.0;
Real ycen = 500.0;
Expand All @@ -194,22 +198,22 @@ Problem::init_custom_terrain (
// Populate bottom plane
int k0 = domlo_z;

for ( amrex::MFIter mfi(z_phys_nd,amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi )
for ( MFIter mfi(z_phys_nd,TilingIfNotGPU()); mfi.isValid(); ++mfi )
{
amrex::Box zbx = mfi.nodaltilebox(2);
Box zbx = mfi.nodaltilebox(2);
if (zbx.smallEnd(2) > k0) continue;

// Grown box with no z range
amrex::Box xybx = mfi.growntilebox(ngrow);
Box xybx = mfi.growntilebox(ngrow);
xybx.setRange(2,0);

amrex::Array4<Real> const& z_arr = z_phys_nd.array(mfi);
Array4<Real> const& z_arr = z_phys_nd.array(mfi);

ParallelFor(xybx, [=] AMREX_GPU_DEVICE (int i, int j, int)
{
// Clip indices for ghost-cells
int ii = amrex::min(amrex::max(i,domlo_x),domhi_x);
int jj = amrex::min(amrex::max(j,domlo_y),domhi_y);
int ii = min(max(i,domlo_x),domhi_x);
int jj = min(max(j,domlo_y),domhi_y);

// Location of nodes
Real x = ProbLoArr[0] + ii * dx[0] - xcen;
Expand Down
Loading

0 comments on commit 542d1fc

Please sign in to comment.