diff --git a/Docs/sphinx_doc/Inputs.rst b/Docs/sphinx_doc/Inputs.rst index 26c4d569c..ca3101631 100644 --- a/Docs/sphinx_doc/Inputs.rst +++ b/Docs/sphinx_doc/Inputs.rst @@ -791,26 +791,32 @@ advantage of this option, the code must be built with ``USE_POISSON_SOLVE = TRUE List of Parameters ------------------ -+----------------------------------+-------------------+--------------------+------------+ -| Parameter | Definition | Acceptable | Default | -| | | Values | | -+==================================+===================+====================+============+ -| **erf.init_type** | Initialization | “custom”, | “*custom*” | -| | type | “ideal”, | | -| | | "real", | | -| | |"input_sounding" | | -+----------------------------------+-------------------+--------------------+------------+ -| **erf.nc_init_file** | NetCDF file with | String | NONE | -| | initial mesoscale | | | -| | data | | | -+----------------------------------+-------------------+--------------------+------------+ -| **erf.nc_bdy_file** | NetCDF file with | String | NONE | -| | mesoscale data at | | | -| | lateral boundaries| | | -+----------------------------------+-------------------+--------------------+------------+ -| **erf.project_initial_velocity** | project initial | Integer | 1 | -| | velocity? | | | -+----------------------------------+-------------------+--------------------+------------+ ++----------------------------------+-------------------+--------------------+--------------+ +| Parameter | Definition | Acceptable | Default | +| | | Values | | ++==================================+===================+====================+==============+ +| **erf.init_type** | Initialization | “custom”, | “*custom*” | +| | type | “ideal”, | | +| | | "real", | | +| | |"input_sounding" | | ++----------------------------------+-------------------+--------------------+--------------+ +| **erf.use_real_bcs** | If init_type is | true or false | true if | +| | real or metgrid, | | if init_type | +| | do we want to use | | is real or | +| | these bcs? | | metgrid; | +| | | | else false | ++----------------------------------+-------------------+--------------------+--------------+ +| **erf.nc_init_file** | NetCDF file with | String | NONE | +| | initial mesoscale | | | +| | data | | | ++----------------------------------+-------------------+--------------------+--------------+ +| **erf.nc_bdy_file** | NetCDF file with | String | NONE | +| | mesoscale data at | | | +| | lateral boundaries| | | ++----------------------------------+-------------------+--------------------+--------------+ +| **erf.project_initial_velocity** | project initial | Integer | 1 | +| | velocity? | | | ++----------------------------------+-------------------+--------------------+--------------+ Notes ----------------- diff --git a/Source/BoundaryConditions/ERF_FillPatch.cpp b/Source/BoundaryConditions/ERF_FillPatch.cpp index d7751995a..6cbfaf1e8 100644 --- a/Source/BoundaryConditions/ERF_FillPatch.cpp +++ b/Source/BoundaryConditions/ERF_FillPatch.cpp @@ -91,8 +91,10 @@ ERF::FillPatch (int lev, Real time, const Vector& 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,false,0,ncomp_cons); - if (init_type == "metgrid" && lev==0) fill_from_metgrid(mfs,time,false,0,ncomp_cons); + if (use_real_bcs) { + if (init_type == "real" && lev==0) fill_from_wrfbdy (mfs,time,false,0,ncomp_cons); + if (init_type == "metgrid" && lev==0) fill_from_metgrid(mfs,time,false,0,ncomp_cons); + } #endif if (m_r2d) fill_from_bndryregs(mfs,time); @@ -132,7 +134,7 @@ ERF::FillPatchMoistVars (int lev, MultiFab& mf) IntVect ngvect_cons = mf.nGrowVect(); IntVect ngvect_vels = {0,0,0}; - if ((init_type != "real") and (init_type != "metgrid")) { + if ((init_type != "real") && (init_type != "metgrid")) { (*physbcs[lev])({&mf},icomp_cons,ncomp_cons,ngvect_cons,ngvect_vels,init_type,cons_only,bccomp_cons); } @@ -248,10 +250,10 @@ ERF::FillIntermediatePatch (int lev, Real time, #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, cons_only, icomp_cons, ncomp_cons); - if (init_type == "metgrid" && lev==0) fill_from_metgrid(mfs,time, cons_only, icomp_cons, ncomp_cons); + if (use_real_bcs) { + if (init_type == "real" && lev==0) fill_from_wrfbdy(mfs,time, cons_only, icomp_cons, ncomp_cons); + if (init_type == "metgrid" && lev==0) fill_from_metgrid(mfs,time, cons_only, icomp_cons, ncomp_cons); + } #endif if (m_r2d) fill_from_bndryregs(mfs,time); diff --git a/Source/BoundaryConditions/ERF_PhysBCFunct.cpp b/Source/BoundaryConditions/ERF_PhysBCFunct.cpp index eafea677a..55df42398 100644 --- a/Source/BoundaryConditions/ERF_PhysBCFunct.cpp +++ b/Source/BoundaryConditions/ERF_PhysBCFunct.cpp @@ -82,7 +82,7 @@ void ERFPhysBCFunct::operator() (const Vector& mfs, int icomp_cons, i z_nd_arr = m_z_phys_nd->const_array(mfi); } - if ((init_type != "real") and (init_type != "metgrid")) + if ((init_type != "real") && (init_type != "metgrid")) { //! If there are cells not in the valid + periodic grown box @@ -109,7 +109,7 @@ void ERFPhysBCFunct::operator() (const Vector& mfs, int icomp_cons, i impose_lateral_zvel_bcs(velz_arr,velx_arr,vely_arr,zbx,domain,z_nd_arr,dxInv,BCVars::zvel_bc); } // !cons_only - } // init_type != "real" and init_type != "metgrid" + } // init_type != "real" && init_type != "metgrid" // Every grid touches the bottom and top domain boundary so we call the vertical bcs // for every box -- and we need to call these even if init_type == real diff --git a/Source/ERF.H b/Source/ERF.H index 8c3779580..4d2c65827 100644 --- a/Source/ERF.H +++ b/Source/ERF.H @@ -700,6 +700,10 @@ private: // init_type: "ideal", "real", "input_sounding", "metgrid" or "" static std::string init_type; + // use_real_bcs: only true if 1) ( (init_type == real) or (init_type == metgrid) ) + // AND 2) we want to use the bc's from the WRF bdy file + static bool use_real_bcs; + // NetCDF initialization (wrfinput) file static amrex::Vector> nc_init_file; diff --git a/Source/ERF.cpp b/Source/ERF.cpp index c998dfc6b..904addc28 100644 --- a/Source/ERF.cpp +++ b/Source/ERF.cpp @@ -53,6 +53,10 @@ std::string ERF::plotfile_type = "amrex"; // init_type: "uniform", "ideal", "real", "input_sounding", "metgrid" or "" std::string ERF::init_type; +// use_real_bcs: only true if 1) ( (init_type == real) or (init_type == metgrid) ) +// AND 2) we want to use the bc's from the WRF bdy file +bool ERF::use_real_bcs; + // NetCDF wrfinput (initialization) file(s) amrex::Vector> ERF::nc_init_file = {{""}}; // Must provide via input @@ -1007,6 +1011,11 @@ ERF::ReadParameters () amrex::Error("if specified, init_type must be uniform, ideal, real, metgrid or input_sounding"); } + // Should we use the bcs we've read in from wrfbdy or metgrid files? + // We default to yes if we have them, but the user can override that option + use_real_bcs = ( (init_type == "real") || (init_type == "metgrid") ); + pp.query("use_real_bcs",use_real_bcs); + // No moving terrain with init real if (init_type == "real" && solverChoice.terrain_type != TerrainType::Static) { amrex::Abort("Moving terrain is not supported with init real"); diff --git a/Source/TimeIntegration/TI_slow_rhs_fun.H b/Source/TimeIntegration/TI_slow_rhs_fun.H index 79434e28a..89e5130cb 100644 --- a/Source/TimeIntegration/TI_slow_rhs_fun.H +++ b/Source/TimeIntegration/TI_slow_rhs_fun.H @@ -198,20 +198,22 @@ } #ifdef ERF_USE_NETCDF - // Populate RHS for relaxation zones - if (((init_type == "real") || (init_type == "metgrid")) && level == 0) { - int width, set_width; - if (init_type == "real") { - width = wrfbdy_width; - set_width = wrfbdy_set_width; - } else if (init_type == "metgrid") { - width = metgrid_bdy_width; - set_width = metgrid_bdy_set_width; + // Populate RHS for relaxation zones if using real bcs + if (use_real_bcs) { + if (((init_type == "real") || (init_type == "metgrid")) && level == 0) { + int width, set_width; + if (init_type == "real") { + width = wrfbdy_width; + set_width = wrfbdy_set_width; + } else if (init_type == "metgrid") { + width = metgrid_bdy_width; + set_width = metgrid_bdy_set_width; + } + wrfbdy_compute_interior_ghost_rhs(init_type, bdy_time_interval, start_bdy_time, new_stage_time, slow_dt, + width-1, set_width, fine_geom, + S_rhs, S_data, bdy_data_xlo, bdy_data_xhi, + bdy_data_ylo, bdy_data_yhi); } - wrfbdy_compute_interior_ghost_rhs(init_type, bdy_time_interval, start_bdy_time, new_stage_time, slow_dt, - width-1, set_width, fine_geom, - S_rhs, S_data, bdy_data_xlo, bdy_data_xhi, - bdy_data_ylo, bdy_data_yhi); } #endif @@ -273,7 +275,8 @@ #if defined(ERF_USE_NETCDF) bool moist_zero = false; - if (solverChoice.moisture_type != MoistureType::None && level==0) { + if ( use_real_bcs && (solverChoice.moisture_type != MoistureType::None) && (level==0) ) + { // Flag for moisture relaxation zone if (init_type=="real" && wrfbdy_set_width > 0) moist_zero = true; if (init_type=="metgrid" && metgrid_bdy_set_width > 0) moist_zero = true; diff --git a/Source/Utils/InteriorGhostCells.cpp b/Source/Utils/InteriorGhostCells.cpp index a0d40f422..da899752f 100644 --- a/Source/Utils/InteriorGhostCells.cpp +++ b/Source/Utils/InteriorGhostCells.cpp @@ -150,16 +150,16 @@ wrfbdy_compute_interior_ghost_rhs (const std::string& init_type, int BdyEnd, ivarU, ivarV, ivarR, ivarT; if (init_type == "real") { BdyEnd = WRFBdyVars::NumTypes-3; - ivarU = WRFBdyVars::U; - ivarV = WRFBdyVars::V; - ivarR = WRFBdyVars::R; - ivarT = WRFBdyVars::T; + ivarU = WRFBdyVars::U; + ivarV = WRFBdyVars::V; + ivarR = WRFBdyVars::R; + ivarT = WRFBdyVars::T; } else if (init_type == "metgrid") { BdyEnd = MetGridBdyVars::NumTypes-1; - ivarU = MetGridBdyVars::U; - ivarV = MetGridBdyVars::V; - ivarR = MetGridBdyVars::R; - ivarT = MetGridBdyVars::T; + ivarU = MetGridBdyVars::U; + ivarV = MetGridBdyVars::V; + ivarR = MetGridBdyVars::R; + ivarT = MetGridBdyVars::T; } // Size the FABs