Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
AMLattanzi committed Oct 24, 2023
1 parent fc29170 commit d756bce
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 26 deletions.
4 changes: 0 additions & 4 deletions Source/Diffusion/ComputeQKESourceTerm.H
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ void
ComputeEquilibriumQKE (amrex::Box bx_QKE,
const amrex::Array4<const amrex::Real>& uvel,
const amrex::Array4<const amrex::Real>& vvel,
const amrex::Array4<const amrex::Real>& cell_data,
const amrex::Array4<const amrex::Real>& cell_prim,
const amrex::Array4<const amrex::Real>& tm_arr,
const amrex::Array4<const amrex::Real>& K_turb,
Expand Down Expand Up @@ -57,14 +56,11 @@ ComputeQKESourceTerms (int i, int j, int k,
const amrex::Array4<const amrex::Real>& cell_prim,
const amrex::Array4<const amrex::Real>& K_turb,
const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
const amrex::Box& domain,
amrex::Real pbl_B1_l,
const amrex::Real theta_mean)
{
// Compute some relevant derivatives
amrex::Real dz_inv = cellSizeInv[2];
int izmin = domain.smallEnd(2);
int izmax = domain.bigEnd(2);
amrex::Real source_term = 0.0;

amrex::Real dthetadz = 0.5*(cell_prim(i,j,k+1,PrimTheta_comp) - cell_prim(i,j,k-1,PrimTheta_comp))*dz_inv;
Expand Down
1 change: 0 additions & 1 deletion Source/Diffusion/ComputeQKESourceTerm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ void
ComputeEquilibriumQKE (amrex::Box bx_QKE,
const amrex::Array4<const amrex::Real>& uvel,
const amrex::Array4<const amrex::Real>& vvel,
const amrex::Array4<const amrex::Real>& cell_data,
const amrex::Array4<const amrex::Real>& cell_prim,
const amrex::Array4<const amrex::Real>& tm_arr,
const amrex::Array4<const amrex::Real>& K_turb,
Expand Down
8 changes: 2 additions & 6 deletions Source/Diffusion/ComputeTurbulentViscosity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ void
ComputeTurbulentViscosityPBL (const amrex::MultiFab& xvel,
const amrex::MultiFab& yvel,
const amrex::MultiFab& cons_in,
const amrex::MultiFab& cons_old,
amrex::MultiFab& eddyViscosity,
amrex::MultiFab* QKE_equil,
const amrex::Geometry& geom,
Expand Down Expand Up @@ -369,15 +368,13 @@ void ComputeTurbulentViscosity (const amrex::MultiFab& xvel , const amrex::Multi
const amrex::MultiFab& Tau11, const amrex::MultiFab& Tau22, const amrex::MultiFab& Tau33,
const amrex::MultiFab& Tau12, const amrex::MultiFab& Tau13, const amrex::MultiFab& Tau23,
const amrex::MultiFab& cons_in,
const amrex::MultiFab& cons_old,
amrex::MultiFab& eddyViscosity,
amrex::MultiFab& Hfx1, amrex::MultiFab& Hfx2, amrex::MultiFab& Hfx3, amrex::MultiFab& Diss,
amrex::MultiFab* QKE_equil,
const amrex::Geometry& geom,
const amrex::MultiFab& mapfac_u, const amrex::MultiFab& mapfac_v,
const TurbChoice& turbChoice, const Real const_grav,
std::unique_ptr<ABLMost>& most,
const amrex::BCRec* bc_ptr,
bool vert_only)
{
BL_PROFILE_VAR("ComputeTurbulentViscosity()",ComputeTurbulentViscosity);
Expand Down Expand Up @@ -412,8 +409,7 @@ void ComputeTurbulentViscosity (const amrex::MultiFab& xvel , const amrex::Multi
}

if (turbChoice.pbl_type != PBLType::None) {
// NOTE: state_new is passed in for Cons_old (due to ptr swap in advance)
ComputeTurbulentViscosityPBL(xvel, yvel, cons_in, cons_old, eddyViscosity,
QKE_equil, geom, turbChoice, most, vert_only);
ComputeTurbulentViscosityPBL(xvel, yvel, cons_in, eddyViscosity, QKE_equil,
geom, turbChoice, most, vert_only);
}
}
2 changes: 1 addition & 1 deletion Source/Diffusion/DiffusionSrcForState_N.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ DiffusionSrcForState_N (const amrex::Box& bx, const amrex::Box& domain,
amrex::ParallelFor(bx,[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
cell_rhs(i, j, k, qty_index) += ComputeQKESourceTerms(i,j,k,u,v,cell_data,cell_prim,
mu_turb,cellSizeInv,domain,
mu_turb,cellSizeInv,
pbl_B1_l,tm_arr(i,j,0));
});
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Diffusion/DiffusionSrcForState_T.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ DiffusionSrcForState_T (const amrex::Box& bx, const amrex::Box& domain,
amrex::ParallelFor(bx,[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
cell_rhs(i, j, k, qty_index) += ComputeQKESourceTerms(i,j,k,u,v,cell_data,cell_prim,
mu_turb,dxInv,domain,pbl_B1_l,tm_arr(i,j,0));
mu_turb,dxInv,pbl_B1_l,tm_arr(i,j,0));
});
}
}
2 changes: 0 additions & 2 deletions Source/Diffusion/EddyViscosity.H
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ ComputeTurbulentViscosity (const amrex::MultiFab& xvel , const amrex::MultiFab&
const amrex::MultiFab& Tau11, const amrex::MultiFab& Tau22, const amrex::MultiFab& Tau33,
const amrex::MultiFab& Tau12, const amrex::MultiFab& Tau13, const amrex::MultiFab& Tau23,
const amrex::MultiFab& cons_in,
const amrex::MultiFab& cons_old,
amrex::MultiFab& eddyViscosity,
amrex::MultiFab& Hfx1,
amrex::MultiFab& Hfx2,
Expand All @@ -23,7 +22,6 @@ ComputeTurbulentViscosity (const amrex::MultiFab& xvel , const amrex::MultiFab&
const amrex::MultiFab& mapfac_u, const amrex::MultiFab& mapfac_v,
const TurbChoice& turbChoice, const amrex::Real const_grav,
std::unique_ptr<ABLMost>& most,
const amrex::BCRec* bc_ptr,
bool vert_only = false);

AMREX_GPU_DEVICE
Expand Down
9 changes: 2 additions & 7 deletions Source/Diffusion/PBLModels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ void
ComputeTurbulentViscosityPBL (const amrex::MultiFab& xvel,
const amrex::MultiFab& yvel,
const amrex::MultiFab& cons_in,
const amrex::MultiFab& cons_old,
amrex::MultiFab& eddyViscosity,
amrex::MultiFab* QKE_equil,
const amrex::Geometry& geom,
Expand All @@ -32,7 +31,7 @@ ComputeTurbulentViscosityPBL (const amrex::MultiFab& xvel,

const amrex::Real A1 = turbChoice.pbl_A1;
const amrex::Real A2 = turbChoice.pbl_A2;
const amrex::Real B1 = turbChoice.pbl_B1;
//const amrex::Real B1 = turbChoice.pbl_B1;
const amrex::Real B2 = turbChoice.pbl_B2;
const amrex::Real C1 = turbChoice.pbl_C1;
const amrex::Real C2 = turbChoice.pbl_C2;
Expand All @@ -50,7 +49,6 @@ ComputeTurbulentViscosityPBL (const amrex::MultiFab& xvel,

const amrex::Box &bx = mfi.growntilebox(1);
const amrex::Array4<amrex::Real const> &cell_data = cons_in.array(mfi);
const amrex::Array4<amrex::Real const> &cell_data_old = cons_old.array(mfi);
const amrex::Array4<amrex::Real > &K_turb = eddyViscosity.array(mfi);
const amrex::Array4<amrex::Real const> &uvel = xvel.array(mfi);
const amrex::Array4<amrex::Real const> &vvel = yvel.array(mfi);
Expand All @@ -69,18 +67,15 @@ ComputeTurbulentViscosityPBL (const amrex::MultiFab& xvel,
const amrex::Box xybx = PerpendicularBox<ZDir>(bx, amrex::IntVect{0,0,0});
amrex::FArrayBox qintegral(xybx,2);
qintegral.setVal<amrex::RunOn::Device>(0.0);
amrex::FArrayBox qturb(bx,1); amrex::FArrayBox qturb_old(bx,1);
amrex::FArrayBox qturb(bx,1);
const amrex::Array4<amrex::Real> qint = qintegral.array();
const amrex::Array4<amrex::Real> qvel = qturb.array();
const amrex::Array4<amrex::Real> qvel_old = qturb_old.array();

amrex::ParallelFor(amrex::Gpu::KernelInfo().setReduction(true), bx,
[=] AMREX_GPU_DEVICE (int i, int j, int k, amrex::Gpu::Handler const& handler) noexcept
{
qvel(i,j,k) = std::sqrt(cell_data(i,j,k,RhoQKE_comp) / cell_data(i,j,k,Rho_comp));
qvel_old(i,j,k) = std::sqrt(cell_data(i,j,k,RhoQKE_comp) / cell_data(i,j,k,Rho_comp) + eps);
AMREX_ASSERT_WITH_MESSAGE(qvel(i,j,k) > 0.0, "QKE must have a positive value");
AMREX_ASSERT_WITH_MESSAGE(qvel_old(i,j,k) > 0.0, "Old QKE must have a positive value");

const amrex::Real Zval = gdata.ProbLo(2) + (k + 0.5)*gdata.CellSize(2);
if (sbx.contains(i,j,k)) {
Expand Down
5 changes: 2 additions & 3 deletions Source/TimeIntegration/ERF_advance_dycore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,14 @@ void ERF::advance_dycore(int level,
// *************************************************************************
if (l_use_kturb)
{
// NOTE: state_new transfers to state_old for PBL (due to ptr swap in advance)
const amrex::BCRec* bc_ptr_d = domain_bcs_type_d.data();
ComputeTurbulentViscosity(xvel_old, yvel_old,
*Tau11, *Tau22, *Tau33,
*Tau12, *Tau13, *Tau23,
state_old[IntVar::cons],state_new[IntVar::cons],
state_old[IntVar::cons],
*eddyDiffs, *Hfx1, *Hfx2, *Hfx3, *Diss, QKE_equil, // to be updated
fine_geom, *mapfac_u[level], *mapfac_v[level],
tc, solverChoice.gravity, m_most, bc_ptr_d);
tc, solverChoice.gravity, m_most);
}

// ***********************************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion Source/TimeIntegration/ERF_slow_rhs_post.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ void erf_slow_rhs_post (int level,
mu_turb, dc, tc, tm_arr, grav_gpu, bc_ptr);
}
if (l_use_mynn) {
ComputeEquilibriumQKE(gbx_QKE, u, v, cur_cons, cur_prim,
ComputeEquilibriumQKE(gbx_QKE, u, v, cur_prim,
tm_arr, mu_turb, QKE_equil_arr,
dxInv, domain, tc.pbl_B1);
}
Expand Down

0 comments on commit d756bce

Please sign in to comment.