Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for failing WPS test. #1261

Merged
merged 3 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions Source/BoundaryConditions/BoundaryConditions_wrfbdy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ using namespace amrex;
*/

void
ERF::fill_from_wrfbdy (const Vector<MultiFab*>& mfs, const Real time)
ERF::fill_from_wrfbdy (const Vector<MultiFab*>& mfs,
const Real time,
bool cons_only,
int icomp_cons,
int ncomp_cons)
{
int lev = 0;

Expand Down Expand Up @@ -46,10 +50,13 @@ ERF::fill_from_wrfbdy (const Vector<MultiFab*>& mfs, const Real time)
ind_map.push_back( {0} ); // zvel

// Nvars to loop over
Vector<int> comp_var = {NVAR, 1, 1, 1};
Vector<int> comp_var = {ncomp_cons, 1, 1, 1};

// End of vars loop
int var_idx_end = (cons_only) ? Vars::cons + 1 : Vars::NumTypes;

// Loop over all variable types
for (int var_idx = Vars::cons; var_idx < Vars::NumTypes; ++var_idx)
for (int var_idx = Vars::cons; var_idx < var_idx_end; ++var_idx)
{
MultiFab& mf = *mfs[var_idx];

Expand All @@ -61,16 +68,18 @@ ERF::fill_from_wrfbdy (const Vector<MultiFab*>& mfs, const Real time)
const auto& dom_lo = amrex::lbound(domain);
const auto& dom_hi = amrex::ubound(domain);

// Offset only applys to cons (we may fill a subset of these vars)
int offset = (var_idx == Vars::cons) ? icomp_cons : 0;

// Loop over each component
for (int comp_idx(0); comp_idx < comp_var[var_idx]; ++comp_idx)
for (int comp_idx(offset); comp_idx < (comp_var[var_idx]+offset); ++comp_idx)
{
int width;
int width = wrfbdy_set_width;;

// Variable can be read from wrf bdy
//------------------------------------
if (is_read[var_idx][comp_idx])
{
width = wrfbdy_set_width;
int ivar = ind_map[var_idx][comp_idx];
IntVect ng_vect = mf.nGrowVect(); ng_vect[2] = 0;

Expand Down Expand Up @@ -138,7 +147,6 @@ ERF::fill_from_wrfbdy (const Vector<MultiFab*>& mfs, const Real time)
// Variable not read from wrf bdy
//------------------------------------
} else {
width = wrfbdy_width - 1;
IntVect ng_vect = mf.nGrowVect(); ng_vect[2] = 0;

#ifdef AMREX_USE_OMP
Expand All @@ -158,14 +166,14 @@ ERF::fill_from_wrfbdy (const Vector<MultiFab*>& mfs, const Real time)
ParallelFor(bx_xlo, bx_xhi,
[=] AMREX_GPU_DEVICE (int i, int j, int k)
{
int jj = std::max(j , dom_lo.y);
jj = std::min(jj, dom_hi.y);
int jj = std::max(j , dom_lo.y+width);
jj = std::min(jj, dom_hi.y-width);
dest_arr(i,j,k,comp_idx) = dest_arr(dom_lo.x+width,jj,k,comp_idx);
},
[=] AMREX_GPU_DEVICE (int i, int j, int k)
{
int jj = std::max(j , dom_lo.y);
jj = std::min(jj, dom_hi.y);
int jj = std::max(j , dom_lo.y+width);
jj = std::min(jj, dom_hi.y-width);
dest_arr(i,j,k,comp_idx) = dest_arr(dom_hi.x-width,jj,k,comp_idx);
});

Expand Down
7 changes: 5 additions & 2 deletions Source/BoundaryConditions/ERF_FillPatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ ERF::FillPatch (int lev, Real time, const Vector<MultiFab*>& mfs, bool fillset)

#ifdef ERF_USE_NETCDF
// We call this here because it is an ERF routine
if (init_type=="real" && lev==0) fill_from_wrfbdy(mfs,time);
if (init_type=="real" && lev==0) fill_from_wrfbdy(mfs, time);
#endif

if (m_r2d) fill_from_bndryregs(mfs,time);
Expand Down Expand Up @@ -245,8 +245,11 @@ ERF::FillIntermediatePatch (int lev, Real time,
IntVect ngvect_vels = IntVect(ng_vel ,ng_vel ,ng_vel);

#ifdef ERF_USE_NETCDF
// NOTE: This routine needs to be aware of what FillIntermediatePatch is operating on
// --- i.e., cons_only and which cons indices (icomp_cons & ncomp_cons)

// We call this here because it is an ERF routine
if (init_type=="real" && lev==0) fill_from_wrfbdy(mfs,time);
if (init_type=="real" && lev==0) fill_from_wrfbdy(mfs, time, cons_only, icomp_cons, ncomp_cons);
#endif

if (m_r2d) fill_from_bndryregs(mfs,time);
Expand Down
5 changes: 4 additions & 1 deletion Source/ERF.H
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,10 @@ public:

#ifdef ERF_USE_NETCDF
void fill_from_wrfbdy (const amrex::Vector<amrex::MultiFab*>& mfs,
amrex::Real time);
amrex::Real time,
bool cons_only = false,
int icomp_cons = 0,
int ncomp_cons = NVAR);
#endif

#ifdef ERF_USE_PARTICLES
Expand Down