Skip to content

Commit

Permalink
Check if we have most before updating it.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Lattanzi committed Feb 4, 2025
1 parent aaa2660 commit 670029b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
27 changes: 15 additions & 12 deletions Source/BoundaryConditions/ERF_MOSTAverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ MOSTAverage::MOSTAverage (Vector<Geometry> geom,
pp.query("most.use_interpolation",m_interp);
pp.query("most.use_normal_vector",m_norm_vec);

// m_time_window is normalized by the time-step "dt"
pp.query("most.time_window", m_time_window);

// Corrections to the mean surface velocity
pp.query("most.include_subgrid_vel", include_subgrid_vel);

// For SYCL
amrex::ignore_unused(has_zphys);

Expand Down Expand Up @@ -62,7 +68,6 @@ MOSTAverage::make_MOSTAverage_at_level (const int& lev,
std::unique_ptr<MultiFab>& Qr_prim,
std::unique_ptr<MultiFab>& z_phys_nd)
{
ParmParse pp(m_pp_prefix);
m_fields[lev].resize(m_nvar);
m_rot_fields[lev].resize(m_nvar-1);
m_averages[lev].resize(m_navg);
Expand Down Expand Up @@ -194,9 +199,6 @@ MOSTAverage::make_MOSTAverage_at_level (const int& lev,
// Set up the exponential time filtering
//--------------------------------------------------------
if (m_t_avg) {
// m_time_window is normalized by the time-step "dt"
pp.query("most.time_window", m_time_window);

// Exponential filter function
m_fact_old = std::exp(-1.0 / m_time_window);

Expand All @@ -208,16 +210,17 @@ MOSTAverage::make_MOSTAverage_at_level (const int& lev,
}

// Corrections to the mean surface velocity
pp.query("most.include_subgrid_vel", include_subgrid_vel);
m_Vsg = Vector<Real>(m_maxlev, 0.0);
if (include_subgrid_vel) {
Print() << "Subgrid velocity scale correction at level : " << lev << ' ';
const auto dxArr = m_geom[lev].CellSizeArray();
Real dx = std::sqrt(dxArr[0]*dxArr[1]);
if (dx > 5000.) {
m_Vsg[lev] = 0.32 * std::pow(dx/5000.-1, 0.33);
m_Vsg = Vector<Real>(m_maxlev, 0.0);
if (include_subgrid_vel) {
Print() << "Subgrid velocity scale correction at level : " << lev << ' ';
const auto dxArr = m_geom[lev].CellSizeArray();
Real dx = std::sqrt(dxArr[0]*dxArr[1]);
if (dx > 5000.) {
m_Vsg[lev] = 0.32 * std::pow(dx/5000.-1, 0.33);
}
Print() << m_Vsg[lev] << std::endl;
}
Print() << m_Vsg[lev] << std::endl;
}
}

Expand Down
36 changes: 20 additions & 16 deletions Source/ERF_MakeNewLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,16 @@ ERF::MakeNewLevelFromCoarse (int lev, Real time, const BoxArray& ba,
// ********************************************************************************************
// Create the MOST arrays at this (new) level
// ********************************************************************************************
int nlevs = finest_level+1;
Vector<MultiFab*> mfv_old = {&vars_old[lev][Vars::cons], &vars_old[lev][Vars::xvel],
&vars_old[lev][Vars::yvel], &vars_old[lev][Vars::zvel]};
m_most->make_MOST_at_level(lev,nlevs,
mfv_old, Theta_prim[lev], Qv_prim[lev],
Qr_prim[lev], z_phys_nd[lev],
Hwave[lev].get(),Lwave[lev].get(),eddyDiffs_lev[lev].get(),
lsm_data[lev], lsm_flux[lev], sst_lev[lev], lmask_lev[lev]);
if (phys_bc_type[Orientation(Direction::z,Orientation::low)] == ERF_BC::MOST) {
int nlevs = finest_level+1;
Vector<MultiFab*> mfv_old = {&vars_old[lev][Vars::cons], &vars_old[lev][Vars::xvel],
&vars_old[lev][Vars::yvel], &vars_old[lev][Vars::zvel]};
m_most->make_MOST_at_level(lev,nlevs,
mfv_old, Theta_prim[lev], Qv_prim[lev],
Qr_prim[lev], z_phys_nd[lev],
Hwave[lev].get(),Lwave[lev].get(),eddyDiffs_lev[lev].get(),
lsm_data[lev], lsm_flux[lev], sst_lev[lev], lmask_lev[lev]);
}

#ifdef ERF_USE_PARTICLES
// particleData.Redistribute();
Expand Down Expand Up @@ -476,14 +478,16 @@ ERF::RemakeLevel (int lev, Real time, const BoxArray& ba, const DistributionMapp
// ********************************************************************************************
// Update the MOST arrays at this level
// ********************************************************************************************
int nlevs = finest_level+1;
Vector<MultiFab*> mfv_old = {&vars_old[lev][Vars::cons], &vars_old[lev][Vars::xvel],
&vars_old[lev][Vars::yvel], &vars_old[lev][Vars::zvel]};
m_most->make_MOST_at_level(lev,nlevs,
mfv_old, Theta_prim[lev], Qv_prim[lev],
Qr_prim[lev], z_phys_nd[lev],
Hwave[lev].get(),Lwave[lev].get(),eddyDiffs_lev[lev].get(),
lsm_data[lev], lsm_flux[lev], sst_lev[lev], lmask_lev[lev]);
if (phys_bc_type[Orientation(Direction::z,Orientation::low)] == ERF_BC::MOST) {
int nlevs = finest_level+1;
Vector<MultiFab*> mfv_old = {&vars_old[lev][Vars::cons], &vars_old[lev][Vars::xvel],
&vars_old[lev][Vars::yvel], &vars_old[lev][Vars::zvel]};
m_most->make_MOST_at_level(lev,nlevs,
mfv_old, Theta_prim[lev], Qv_prim[lev],
Qr_prim[lev], z_phys_nd[lev],
Hwave[lev].get(),Lwave[lev].get(),eddyDiffs_lev[lev].get(),
lsm_data[lev], lsm_flux[lev], sst_lev[lev], lmask_lev[lev]);
}

#ifdef ERF_USE_PARTICLES
particleData.Redistribute();
Expand Down

0 comments on commit 670029b

Please sign in to comment.