Skip to content

Commit

Permalink
Merge branch 'development' into turn_on_reflux_2
Browse files Browse the repository at this point in the history
  • Loading branch information
asalmgren authored Nov 13, 2023
2 parents 7f4d794 + e79c8e1 commit b33b711
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions Exec/RegTests/GABLS1/prob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,28 @@ Problem::init_custom_pert(
amrex::Array4<amrex::Real const> const& /*mf_v*/,
const SolverChoice& /*sc*/)
{
if (state.nComp() > RhoQKE_comp) {
amrex::Print() << "Initializing QKE" << std::endl;
}

if (parms.pert_ref_height > 0) {
if (parms.pert_deltaU != 0.0) {
amrex::Print() << "Adding divergence-free x-velocity perturbations" << std::endl;
}
if (parms.pert_deltaV != 0.0) {
amrex::Print() << "Adding divergence-free y-velocity perturbations" << std::endl;
}
if (parms.T_0_Pert_Mag != 0.0) {
amrex::Print() << "Adding random theta perturbations" << std::endl;
}
if (parms.U_0_Pert_Mag != 0.0) {
amrex::Print() << "Adding random x-velocity perturbations" << std::endl;
}
if (parms.V_0_Pert_Mag != 0.0) {
amrex::Print() << "Adding random y-velocity perturbations" << std::endl;
}
}

ParallelForRNG(bx, [=, parms=parms] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine& engine) noexcept {
// Geometry
const Real* prob_lo = geomdata.ProbLo();
Expand All @@ -89,18 +111,20 @@ Problem::init_custom_pert(
// Add temperature perturbations
if ((z <= parms.pert_ref_height) && (parms.T_0_Pert_Mag != 0.0)) {
Real rand_double = amrex::Random(engine); // Between 0.0 and 1.0
state(i, j, k, RhoTheta_comp) = (rand_double*2.0 - 1.0)*parms.T_0_Pert_Mag;
state(i, j, k, RhoTheta_comp) = r_hse(i,j,k) * (rand_double*2.0 - 1.0)*parms.T_0_Pert_Mag;
}

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

// Set an initial value for QKE = 2*e
if (z < 250) {
// Following Cuxart et al. 2006
state(i, j, k, RhoQKE_comp) = r_hse(i,j,k) * 0.8 * std::pow(1 - z/250, 3);
} else {
state(i, j, k, RhoQKE_comp) = r_hse(i,j,k) * parms.QKE_0;
if (state.nComp() > RhoQKE_comp) {
if (z < 250) {
// Following Cuxart et al. 2006
state(i, j, k, RhoQKE_comp) = r_hse(i,j,k) * 0.8 * std::pow(1 - z/250, 3);
} else {
state(i, j, k, RhoQKE_comp) = r_hse(i,j,k) * parms.QKE_0;
}
}

#if defined(ERF_USE_MOISTURE)
Expand Down Expand Up @@ -130,7 +154,7 @@ Problem::init_custom_pert(
if (parms.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.pert_ref_height/2);
const amrex::Real damp = std::exp(-0.5 * zl * zl);
x_vel(i, j, k) += parms.ufac * damp * z * std::cos(parms.aval * yl);
}
Expand Down

0 comments on commit b33b711

Please sign in to comment.