From dc03e053b8c3b77de9203e54f0ca847c8247f571 Mon Sep 17 00:00:00 2001 From: AMLattanzi Date: Thu, 14 Dec 2023 16:43:06 -0800 Subject: [PATCH] NullMoist doesn't have a mic_fab_var data structure. Prevent touching qmoist without a moisture model. --- Source/BoundaryConditions/ERF_FillPatch.cpp | 4 +- Source/TimeIntegration/ERF_advance_dycore.cpp | 50 ++++++++++--------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Source/BoundaryConditions/ERF_FillPatch.cpp b/Source/BoundaryConditions/ERF_FillPatch.cpp index 8ac3006f1..68270c55a 100644 --- a/Source/BoundaryConditions/ERF_FillPatch.cpp +++ b/Source/BoundaryConditions/ERF_FillPatch.cpp @@ -100,7 +100,7 @@ ERF::FillPatch (int lev, Real time, const Vector& mfs, bool fillset) // We call this even if init_type == real because this routine will fill the vertical bcs (*physbcs[lev])(mfs,icomp_cons,ncomp_cons,ngvect_cons,ngvect_vels,init_type,cons_only,BCVars::cons_bc,time); - // Update vars and pointers if we have a micro model + // Update vars in the micro model if (solverChoice.moisture_type != MoistureType::None) micro.Update_Micro_Vars_Lev(lev, vars_new[lev][Vars::cons]); } @@ -262,7 +262,7 @@ ERF::FillIntermediatePatch (int lev, Real time, if (!(cons_only && ncomp_cons == 1) && m_most && allow_most_bcs) m_most->impose_most_bcs(lev,mfs,eddyDiffs_lev[lev].get(),z_phys_nd[lev].get()); - // Update vars and pointers if we have a micro model + // Update vars in the micro model if (solverChoice.moisture_type != MoistureType::None) micro.Update_Micro_Vars_Lev(lev, vars_new[lev][Vars::cons]); } diff --git a/Source/TimeIntegration/ERF_advance_dycore.cpp b/Source/TimeIntegration/ERF_advance_dycore.cpp index 101918fd9..b963b56e0 100644 --- a/Source/TimeIntegration/ERF_advance_dycore.cpp +++ b/Source/TimeIntegration/ERF_advance_dycore.cpp @@ -255,38 +255,40 @@ void ERF::advance_dycore(int level, Gpu::DeviceVector qv_d(ncell), qc_d(ncell), qi_d(ncell); - if (q_size >= 1) { - MultiFab qvapor (*(qmoist[level][0]), make_alias, 0, 1); - PlaneAverage qv_ave(&qvapor, geom[level], solverChoice.ave_plane); - qv_ave.compute_averages(ZDir(), qv_ave.field()); + if (solverChoice.moisture_type != MoistureType::None) { + if (q_size >= 1) { + MultiFab qvapor (*(qmoist[level][0]), make_alias, 0, 1); + PlaneAverage qv_ave(&qvapor, geom[level], solverChoice.ave_plane); + qv_ave.compute_averages(ZDir(), qv_ave.field()); - Gpu::HostVector qv_h(ncell); + Gpu::HostVector qv_h(ncell); - qv_ave.line_average(0, qv_h); - Gpu::copyAsync(Gpu::hostToDevice, qv_h.begin(), qv_h.end(), qv_d.begin()); - } + qv_ave.line_average(0, qv_h); + Gpu::copyAsync(Gpu::hostToDevice, qv_h.begin(), qv_h.end(), qv_d.begin()); + } - if (q_size >= 2) { - MultiFab qcloud (*(qmoist[level][1]), make_alias, 0, 1); - PlaneAverage qc_ave(&qcloud, geom[level], solverChoice.ave_plane); - qc_ave.compute_averages(ZDir(), qc_ave.field()); + if (q_size >= 2) { + MultiFab qcloud (*(qmoist[level][1]), make_alias, 0, 1); + PlaneAverage qc_ave(&qcloud, geom[level], solverChoice.ave_plane); + qc_ave.compute_averages(ZDir(), qc_ave.field()); - Gpu::HostVector qc_h(ncell); + Gpu::HostVector qc_h(ncell); - qc_ave.line_average(0, qc_h); - Gpu::copyAsync(Gpu::hostToDevice, qc_h.begin(), qc_h.end(), qc_d.begin()); - } + qc_ave.line_average(0, qc_h); + Gpu::copyAsync(Gpu::hostToDevice, qc_h.begin(), qc_h.end(), qc_d.begin()); + } - if (q_size >= 3) { - MultiFab qice (*(qmoist[level][2]), make_alias, 0, 1); - PlaneAverage qi_ave(&qice , geom[level], solverChoice.ave_plane); - qi_ave.compute_averages(ZDir(), qi_ave.field()); + if (q_size >= 3) { + MultiFab qice (*(qmoist[level][2]), make_alias, 0, 1); + PlaneAverage qi_ave(&qice , geom[level], solverChoice.ave_plane); + qi_ave.compute_averages(ZDir(), qi_ave.field()); - Gpu::HostVector qi_h(ncell); + Gpu::HostVector qi_h(ncell); - qi_ave.line_average(0, qi_h); - Gpu::copyAsync(Gpu::hostToDevice, qi_h.begin(), qi_h.end(), qi_d.begin()); - Gpu::streamSynchronize(); + qi_ave.line_average(0, qi_h); + Gpu::copyAsync(Gpu::hostToDevice, qi_h.begin(), qi_h.end(), qi_d.begin()); + Gpu::streamSynchronize(); + } } #include "TI_no_substep_fun.H"