From e6833b6b76ba7587d1268f24eccfafc8130b53aa Mon Sep 17 00:00:00 2001 From: Mahesh Natarajan Date: Tue, 5 Mar 2024 13:13:58 -0800 Subject: [PATCH] Compute rain accumulation on ground for squall line (#1474) * Compute rain accumulation on ground * Correcting CUDA error --------- Co-authored-by: Mahesh Natarajan Co-authored-by: Ann Almgren --- Source/ERF.H | 2 +- Source/Microphysics/Kessler/Init_Kessler.cpp | 2 +- Source/Microphysics/Kessler/Kessler.H | 3 ++- Source/Microphysics/Kessler/Kessler.cpp | 11 ++++++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Source/ERF.H b/Source/ERF.H index 7b6cd138c..4baedc5a3 100644 --- a/Source/ERF.H +++ b/Source/ERF.H @@ -704,7 +704,7 @@ private: // mynn pbl lengthscale "Lpbl", // moisture vars - "qt", "qv", "qc", "qi", "qp", "qrain", "qsnow", "qgraup" + "qt", "qv", "qc", "qi", "qp", "qrain", "qsnow", "qgraup", "rain_accum", #ifdef ERF_COMPUTE_ERROR ,"xvel_err", "yvel_err", "zvel_err", "pp_err" #endif diff --git a/Source/Microphysics/Kessler/Init_Kessler.cpp b/Source/Microphysics/Kessler/Init_Kessler.cpp index 3b1ed3bc7..ab9084356 100644 --- a/Source/Microphysics/Kessler/Init_Kessler.cpp +++ b/Source/Microphysics/Kessler/Init_Kessler.cpp @@ -29,7 +29,7 @@ void Kessler::Init (const MultiFab& cons_in, m_gtoe = grids; MicVarMap.resize(m_qmoist_size); - MicVarMap = {MicVar_Kess::qt, MicVar_Kess::qv, MicVar_Kess::qcl, MicVar_Kess::qp}; + MicVarMap = {MicVar_Kess::qt, MicVar_Kess::qv, MicVar_Kess::qcl, MicVar_Kess::qp, MicVar_Kess::rain_accum}; // initialize microphysics variables for (auto ivar = 0; ivar < MicVar_Kess::NumVars; ++ivar) { diff --git a/Source/Microphysics/Kessler/Kessler.H b/Source/Microphysics/Kessler/Kessler.H index 0b152efa6..916f5084b 100644 --- a/Source/Microphysics/Kessler/Kessler.H +++ b/Source/Microphysics/Kessler/Kessler.H @@ -38,6 +38,7 @@ namespace MicVar_Kess { // precipitating vars qp, // total precip // derived vars + rain_accum, NumVars }; } @@ -127,7 +128,7 @@ public: private: // Number of qmoist variables (qt, qv, qcl, qp) - int m_qmoist_size = 4; + int m_qmoist_size = 5; // Number of qstate variables int m_qstate_size = 3; diff --git a/Source/Microphysics/Kessler/Kessler.cpp b/Source/Microphysics/Kessler/Kessler.cpp index e3fb058ec..2ef020b69 100644 --- a/Source/Microphysics/Kessler/Kessler.cpp +++ b/Source/Microphysics/Kessler/Kessler.cpp @@ -19,6 +19,8 @@ if(solverChoice.moisture_type == MoistureType::Kessler){ auto pres = mic_fab_vars[MicVar_Kess::pres]; auto theta = mic_fab_vars[MicVar_Kess::theta]; auto rho = mic_fab_vars[MicVar_Kess::rho]; + auto rain_accum = mic_fab_vars[MicVar_Kess::rain_accum]; + auto dz = m_geom.CellSize(2); auto domain = m_geom.Domain(); @@ -30,9 +32,13 @@ if(solverChoice.moisture_type == MoistureType::Kessler){ auto dm = tabs->DistributionMap(); fz.define(convert(ba, IntVect(0,0,1)), dm, 1, 0); // No ghost cells + Real dtn = dt; + for ( MFIter mfi(fz, TilingIfNotGPU()); mfi.isValid(); ++mfi ){ auto rho_array = mic_fab_vars[MicVar_Kess::rho]->array(mfi); auto qp_array = mic_fab_vars[MicVar_Kess::qp]->array(mfi); + auto rain_accum_array = mic_fab_vars[MicVar_Kess::rain_accum]->array(mfi); + auto fz_array = fz.array(mfi); const Box& tbz = mfi.tilebox(); @@ -57,13 +63,16 @@ if(solverChoice.moisture_type == MoistureType::Kessler){ fz_array(i,j,k) = rho_avg*V_terminal*qp_avg; + if(k==k_lo){ + rain_accum_array(i,j,k) = rain_accum_array(i,j,k) + rho_avg*qp_avg*V_terminal*dtn/1000.0*1000.0; // Divide by rho_water and convert to mm + } + /*if(k==0){ fz_array(i,j,k) = 0; }*/ }); } - Real dtn = dt; for ( MFIter mfi(*tabs,TilingIfNotGPU()); mfi.isValid(); ++mfi) { auto qv_array = mic_fab_vars[MicVar_Kess::qv]->array(mfi);