Skip to content

Commit

Permalink
parms --> parms_d (#1689)
Browse files Browse the repository at this point in the history
* parms --> parms_d

* more fixes for HIP CI

* fix typo
  • Loading branch information
asalmgren authored Jul 16, 2024
1 parent 9abf6e0 commit b1f35ac
Show file tree
Hide file tree
Showing 26 changed files with 437 additions and 341 deletions.
58 changes: 29 additions & 29 deletions Exec/ABL/prob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Problem::init_custom_pert(
}
}

ParallelForRNG(bx, [=, d_parms=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 amrex::RandomEngine& engine) noexcept {
// Geometry
const Real* prob_lo = geomdata.ProbLo();
const Real* prob_hi = geomdata.ProbHi();
Expand All @@ -115,36 +115,36 @@ Problem::init_custom_pert(
const Real r = std::sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc) + (z-zc)*(z-zc));

// Add temperature perturbations
if ((z <= d_parms.pert_ref_height) && (d_parms.T_0_Pert_Mag != 0.0)) {
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
state_pert(i, j, k, RhoTheta_comp) = (rand_double*2.0 - 1.0)*d_parms.T_0_Pert_Mag;
if (!d_parms.pert_rhotheta) {
state_pert(i, j, k, RhoTheta_comp) = (rand_double*2.0 - 1.0)*parms_d.T_0_Pert_Mag;
if (!parms_d.pert_rhotheta) {
// we're perturbing theta, not rho*theta
state_pert(i, j, k, RhoTheta_comp) *= r_hse(i,j,k);
}
}

// Set scalar = A_0*exp(-10r^2), where r is distance from center of domain
state_pert(i, j, k, RhoScalar_comp) = d_parms.A_0 * exp(-10.*r*r);
state_pert(i, j, k, RhoScalar_comp) = parms_d.A_0 * exp(-10.*r*r);

// Set an initial value for SGS KE
if (state_pert.nComp() > RhoKE_comp) {
// Deardorff
state_pert(i, j, k, RhoKE_comp) = r_hse(i,j,k) * d_parms.KE_0;
if (d_parms.KE_decay_height > 0) {
state_pert(i, j, k, RhoKE_comp) = r_hse(i,j,k) * parms_d.KE_0;
if (parms_d.KE_decay_height > 0) {
// scale initial SGS kinetic energy with height
state_pert(i, j, k, RhoKE_comp) *= max(
std::pow(1 - min(z/d_parms.KE_decay_height,1.0), d_parms.KE_decay_order),
std::pow(1 - min(z/parms_d.KE_decay_height,1.0), parms_d.KE_decay_order),
1e-12);
}
}
if (state_pert.nComp() > RhoQKE_comp) {
// PBL
state_pert(i, j, k, RhoQKE_comp) = r_hse(i,j,k) * d_parms.QKE_0;
if (d_parms.KE_decay_height > 0) {
state_pert(i, j, k, RhoQKE_comp) = r_hse(i,j,k) * parms_d.QKE_0;
if (parms_d.KE_decay_height > 0) {
// scale initial SGS kinetic energy with height
state_pert(i, j, k, RhoQKE_comp) *= max(
std::pow(1 - min(z/d_parms.KE_decay_height,1.0), d_parms.KE_decay_order),
std::pow(1 - min(z/parms_d.KE_decay_height,1.0), parms_d.KE_decay_order),
1e-12);
}
}
Expand All @@ -156,7 +156,7 @@ Problem::init_custom_pert(
});

// Set the x-velocity
ParallelForRNG(xbx, [=, d_parms=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 amrex::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 @@ -165,24 +165,24 @@ Problem::init_custom_pert(
: prob_lo[2] + (k + 0.5) * dx[2];

// Set the x-velocity
x_vel_pert(i, j, k) = d_parms.U_0;
if ((z <= d_parms.pert_ref_height) && (d_parms.U_0_Pert_Mag != 0.0))
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 x_vel_prime = (rand_double*2.0 - 1.0)*d_parms.U_0_Pert_Mag;
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 (d_parms.pert_deltaU != 0.0)
if (parms_d.pert_deltaU != 0.0)
{
const amrex::Real yl = y - prob_lo[1];
const amrex::Real zl = z / d_parms.pert_ref_height;
const amrex::Real zl = z / parms_d.pert_ref_height;
const amrex::Real damp = std::exp(-0.5 * zl * zl);
x_vel_pert(i, j, k) += d_parms.ufac * damp * z * std::cos(d_parms.aval * yl);
x_vel_pert(i, j, k) += parms_d.ufac * damp * z * std::cos(parms_d.aval * yl);
}
});

// Set the y-velocity
ParallelForRNG(ybx, [=, d_parms=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 amrex::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 @@ -191,24 +191,24 @@ Problem::init_custom_pert(
: prob_lo[2] + (k + 0.5) * dx[2];

// Set the y-velocity
y_vel_pert(i, j, k) = d_parms.V_0;
if ((z <= d_parms.pert_ref_height) && (d_parms.V_0_Pert_Mag != 0.0))
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 y_vel_prime = (rand_double*2.0 - 1.0)*d_parms.V_0_Pert_Mag;
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 (d_parms.pert_deltaV != 0.0)
if (parms_d.pert_deltaV != 0.0)
{
const amrex::Real xl = x - prob_lo[0];
const amrex::Real zl = z / d_parms.pert_ref_height;
const amrex::Real zl = z / parms_d.pert_ref_height;
const amrex::Real damp = std::exp(-0.5 * zl * zl);
y_vel_pert(i, j, k) += d_parms.vfac * damp * z * std::cos(d_parms.bval * xl);
y_vel_pert(i, j, k) += parms_d.vfac * damp * z * std::cos(parms_d.bval * xl);
}
});

// Set the z-velocity
ParallelForRNG(zbx, [=, d_parms=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 amrex::RandomEngine& engine) noexcept {
const int dom_lo_z = geomdata.Domain().smallEnd()[2];
const int dom_hi_z = geomdata.Domain().bigEnd()[2];

Expand All @@ -217,11 +217,11 @@ Problem::init_custom_pert(
{
z_vel_pert(i, j, k) = 0.0;
}
else if (d_parms.W_0_Pert_Mag != 0.0)
else if (parms_d.W_0_Pert_Mag != 0.0)
{
Real rand_double = amrex::Random(engine); // Between 0.0 and 1.0
Real z_vel_prime = (rand_double*2.0 - 1.0)*d_parms.W_0_Pert_Mag;
z_vel_pert(i, j, k) = d_parms.W_0 + z_vel_prime;
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;
}
});
}
42 changes: 21 additions & 21 deletions Exec/ABL_input_sounding/prob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Problem::init_custom_pert(
{
const bool use_moisture = (sc.moisture_type != MoistureType::None);

ParallelFor(bx, [=, parms=parms] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
ParallelFor(bx, [=, parms_d=parms] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
// Geometry
const Real* prob_lo = geomdata.ProbLo();
const Real* prob_hi = geomdata.ProbHi();
Expand All @@ -81,10 +81,10 @@ Problem::init_custom_pert(
const Real r = std::sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc) + (z-zc)*(z-zc));

// Set scalar = A_0*exp(-10r^2), where r is distance from center of domain
state_pert(i, j, k, RhoScalar_comp) = parms.A_0 * exp(-10.*r*r);
state_pert(i, j, k, RhoScalar_comp) = parms_d.A_0 * exp(-10.*r*r);

// Set an initial value for QKE
state_pert(i, j, k, RhoQKE_comp) = parms.QKE_0;
state_pert(i, j, k, RhoQKE_comp) = parms_d.QKE_0;

if (use_moisture) {
state_pert(i, j, k, RhoQ1_comp) = 0.0;
Expand All @@ -93,55 +93,55 @@ Problem::init_custom_pert(
});

// Set the x-velocity
ParallelForRNG(xbx, [=, parms=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 amrex::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];
const Real z = prob_lo[2] + (k + 0.5) * dx[2];

// Set the x-velocity
x_vel_pert(i, j, k) = parms.U_0;
if ((z <= parms.pert_ref_height) && (parms.U_0_Pert_Mag != 0.0))
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 x_vel_prime = (rand_double*2.0 - 1.0)*parms.U_0_Pert_Mag;
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.pert_deltaU != 0.0)
if (parms_d.pert_deltaU != 0.0)
{
const amrex::Real yl = y - prob_lo[1];
const amrex::Real zl = z / parms.pert_ref_height;
const amrex::Real zl = z / parms_d.pert_ref_height;
const amrex::Real damp = std::exp(-0.5 * zl * zl);
x_vel_pert(i, j, k) += parms.ufac * damp * z * std::cos(parms.aval * yl);
x_vel_pert(i, j, k) += parms_d.ufac * damp * z * std::cos(parms_d.aval * yl);
}
});

// Set the y-velocity
ParallelForRNG(ybx, [=, parms=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 amrex::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];
const Real z = prob_lo[2] + (k + 0.5) * dx[2];

// Set the y-velocity
y_vel_pert(i, j, k) = parms.V_0;
if ((z <= parms.pert_ref_height) && (parms.V_0_Pert_Mag != 0.0))
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 y_vel_prime = (rand_double*2.0 - 1.0)*parms.V_0_Pert_Mag;
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.pert_deltaV != 0.0)
if (parms_d.pert_deltaV != 0.0)
{
const amrex::Real xl = x - prob_lo[0];
const amrex::Real zl = z / parms.pert_ref_height;
const amrex::Real zl = z / parms_d.pert_ref_height;
const amrex::Real damp = std::exp(-0.5 * zl * zl);
y_vel_pert(i, j, k) += parms.vfac * damp * z * std::cos(parms.bval * xl);
y_vel_pert(i, j, k) += parms_d.vfac * damp * z * std::cos(parms_d.bval * xl);
}
});

// Set the z-velocity
ParallelForRNG(zbx, [=, parms=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 amrex::RandomEngine& engine) noexcept
{
const int dom_lo_z = geomdata.Domain().smallEnd()[2];
const int dom_hi_z = geomdata.Domain().bigEnd()[2];
Expand All @@ -151,11 +151,11 @@ Problem::init_custom_pert(
{
z_vel_pert(i, j, k) = 0.0;
}
else if (parms.W_0_Pert_Mag != 0.0)
else if (parms_d.W_0_Pert_Mag != 0.0)
{
Real rand_double = amrex::Random(engine); // Between 0.0 and 1.0
Real z_vel_prime = (rand_double*2.0 - 1.0)*parms.W_0_Pert_Mag;
z_vel_pert(i, j, k) = parms.W_0 + z_vel_prime;
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;
}
});
}
99 changes: 99 additions & 0 deletions Exec/DevTests/ABL_perturbation_inflow/incompressible_inputs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
start_time = 0.
stop_time = 35.0
#stop_time = 10.0

erf.incompressible = 1
erf.no_substepping = 1

#max_step = 1000

amrex.fpe_trap_invalid = 1

fabarray.mfiter_tile_size = 1024 1024 1024

# PROBLEM SIZE & GEOMETRY
#geometry.prob_extent = 4. 1. 1.
#amr.n_cell = 128 32 32

geometry.prob_extent = 10. 1. 1.
#amr.n_cell = 128 16 16
amr.n_cell = 128 16 64

geometry.is_periodic = 0 1 0

xlo.type = "Outflow"
xhi.type = "Outflow"
zlo.type = "NoSlipWall"
zhi.type = "SlipWall"

# TIME STEP CONTROL
erf.cfl = 0.5

erf.dynamicViscosity = 0.0001 # H = 1, therefore utau = 0.2

# DIAGNOSTICS & VERBOSITY
erf.sum_interval = 1 # timesteps between computing mass
erf.pert_interval = 1 # timesteps between perturbation output message
erf.v = 1 # verbosity in ERF.cpp
erf.mg_v = 2 # verbosity in ERF.cpp
amr.v = 0 # verbosity in Amr.cpp

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

# PLOTFILES
erf.plot_file_1 = plt # prefix of plotfile name
#erf.plot_per_1 = 0.1
erf.plot_int_1 = 10
erf.plot_vars_1 = density rhoadv_0 x_velocity y_velocity z_velocity pressure temp theta

# CHECKPOINT FILES
erf.check_file = chk # root name of checkpoint file
erf.check_per = 1.0

# Restart for data collection
#erf.restart = "/home/tma/Desktop/TurbChannel/SpinUp/chk233334"
#erf.data_log = "surf.txt" "mean.txt" "flux.txt" "subgrid.txt"
#erf.profile_int = 33334

# SOLVER CHOICE
erf.alpha_T = 0.0
erf.alpha_C = 1.0
erf.use_gravity = false

erf.molec_diff_type = "None"
erf.les_type = "Smagorinsky"
erf.Cs = 0.1

erf.buoyancy_type = 1

# Initial condition for the entire field
erf.init_type = "input_sounding"
erf.input_sounding_file = "input_ReTau2000DNS_sounding.txt"

# Inflow boundary condition
erf.sponge_type = "input_sponge"
erf.input_sponge_file = "input_ReTau2000DNS_sponge.txt"
erf.sponge_strength = 100000.0
erf.use_xlo_sponge_damping = true
erf.xlo_sponge_end = 1.0

# Turbulent inflow generation
erf.perturbation_type = "source"
erf.perturbation_direction = 1 0 0
erf.perturbation_layers = 3
erf.perturbation_offset = 0

erf.perturbation_box_dims = 4 4 8 # 0.25 0.25 0.125
erf.perturbation_nondimensional = 0.042 # Ri
erf.perturbation_T_infinity = 300.0
erf.perturbation_T_intensity = 0.1

# PROBLEM PARAMETERS
prob.rho_0 = 1.0
prob.A_0 = 1.0
prob.U_0 = 0.0
prob.V_0 = 0.0
prob.W_0 = 0.0
prob.T_0 = 300.0
Loading

0 comments on commit b1f35ac

Please sign in to comment.