Skip to content

Commit

Permalink
Merge branch 'development' into SampleData
Browse files Browse the repository at this point in the history
  • Loading branch information
AMLattanzi authored Oct 21, 2024
2 parents db97e5a + e3adba1 commit 8363787
Show file tree
Hide file tree
Showing 27 changed files with 405 additions and 547 deletions.
1 change: 0 additions & 1 deletion Build/cmake_with_poisson.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ cmake -DCMAKE_INSTALL_PREFIX:PATH=./install \
-DCMAKE_Fortran_COMPILER:STRING=mpifort \
-DMPIEXEC_PREFLAGS:STRING=--oversubscribe \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DAMREX_LINEAR_SOLVERS:BOOL=ON \
-DERF_DIM:STRING=3 \
-DERF_ENABLE_MPI:BOOL=ON \
-DERF_ENABLE_TESTS:BOOL=ON \
Expand Down
14 changes: 10 additions & 4 deletions Docs/sphinx_doc/TimeAdvance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,14 @@ Then the acoustic substepping evolves the equations in the form
- \frac{\partial (\beta_1 W^{\prime \prime, \tau} + \beta_2 W^{\prime \prime, \tau + \delta \tau})}{\partial z} + R^t_{\rho}
\right)
where :math:`\beta_1 = 0.5 (1 - \beta_s)` and :math:`\beta_2 = 0.5 (1 + \beta_s)` with :math:`\beta_s = 0.1`.
:math:`\beta_s` is the acoustic step off-centering coefficient and 0.1 is the typical WRF value. This off-centering is intended to provide damping of both horizontally and vertically propagating sound waves by biasing the time average toward the future time step.
where :math:`\beta_1 = 0.5 (1 - \beta_s)` and :math:`\beta_2 = 0.5 (1 + \beta_s)`.

:math:`\beta_s` is the acoustic step off-centering coefficient. When we do implicit substepping, we use
the typical WRF value of 0.1. This off-centering is intended to provide damping of both horizontally
and vertically propagating sound waves by biasing the time average toward the future time step.

When we do fully explicit substepping, we set :math:`\beta_s = -1.0`, which sets
:math:`\beta_1 = 1` and :math:`\beta_2 = 0`.

To solve the coupled system, we first evolve the equations for :math:`U^{\prime \prime, \tau + \delta \tau}` and
:math:`V^{\prime \prime, \tau + \delta \tau}` explicitly using :math:`\Theta^{\prime \prime, \tau}` which is already known.
Expand All @@ -149,10 +155,10 @@ to control horizontally propagating sound waves.
.. math::
p^{\prime\prime,\tau*} = p^{\prime\prime,\tau}
+ \beta_d \left( p^{\prime\prime,\tau} + p^{\prime\prime,\tau-\delta\tau} \right)
+ \beta_d \left( p^{\prime\prime,\tau} - p^{\prime\prime,\tau-\delta\tau} \right)
where :math:`\tau*` is the forward projected value used in RHS of the acoustic
substepping equations for horizontal momentum. According to Skamarock et al,
This is equivalent to including a horizontal diffusion term in the continuity
this is equivalent to including a horizontal diffusion term in the continuity
equation. A typical damping coefficient of :math:`\beta_d = 0.1` is used, as in
WRF.
6 changes: 3 additions & 3 deletions Exec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ elseif (ERF_ENABLE_REGRESSION_TESTS_ONLY)
else ()
add_subdirectory(ABL)
add_subdirectory(SuperCell)
add_subdirectory(Radiation)
add_subdirectory(SquallLine_2D)
add_subdirectory(RegTests/Bubble)
add_subdirectory(RegTests/Couette_Poiseuille)
Expand All @@ -35,9 +34,10 @@ else ()
add_subdirectory(RegTests/WPS_Test)
add_subdirectory(RegTests/Bomex)
add_subdirectory(RegTests/TurbulentInflow)
add_subdirectory(DevTests/MovingTerrain)
add_subdirectory(DevTests/MetGrid)
add_subdirectory(DevTests/LandSurfaceModel)
add_subdirectory(DevTests/MetGrid)
add_subdirectory(DevTests/MovingTerrain)
add_subdirectory(DevTests/Radiation)
add_subdirectory(DevTests/TemperatureSource)
add_subdirectory(DevTests/TropicalCyclone)
endif()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 2 additions & 16 deletions Exec/Make.ERF
Original file line number Diff line number Diff line change
Expand Up @@ -183,22 +183,8 @@ INCLUDE_LOCATIONS += $(ERF_WINDFARM_GENERALAD_DIR)

endif

ifeq ($(USE_HEFFTE),TRUE)
DEFINES += -DERF_USE_HEFFTE
VPATH_LOCATIONS += $(HEFFTE_HOME)/include
INCLUDE_LOCATIONS += $(HEFFTE_HOME)/include
LIBRARY_LOCATIONS += $(HEFFTE_HOME)/lib
LIBRARIES += -lheffte
ifeq ($(USE_CUDA),TRUE)
libraries += -lcufft
else ifeq ($(USE_HIP),TRUE)
# Use rocFFT. ROC_PATH is defined in amrex
INCLUDE_LOCATIONS += $(ROC_PATH)/rocfft/include
LIBRARY_LOCATIONS += $(ROC_PATH)/rocfft/lib
LIBRARIES += -L$(ROC_PATH)/rocfft/lib -lrocfft
else
libraries += -lfftw3_mpi -lfftw3f -lfftw3
endif
ifeq ($(USE_FFT),TRUE)
DEFINES += -DERF_USE_FFT
endif

ifeq ($(USE_WW3_COUPLING), TRUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using namespace amrex;

void ERFPhysBCFunct_base::impose_lateral_basestate_bcs (const Array4<Real>& dest_arr, const Box& bx, const Box& domain)
{
BL_PROFILE_VAR("impose_lateral_cons_bcs()",impose_lateral_cons_bcs);
BL_PROFILE_VAR("impose_lateral_base_bcs()",impose_lateral_base_bcs);

int icomp = 0;
int ncomp = 3;
Expand Down
2 changes: 1 addition & 1 deletion Source/BoundaryConditions/ERF_BoundaryConditions_cons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void ERFPhysBCFunct_cons::impose_vertical_cons_bcs (const Array4<Real>& dest_arr
const GpuArray<Real,AMREX_SPACEDIM> dxInv,
int icomp, int ncomp)
{
BL_PROFILE_VAR("impose_lateral_cons_bcs()",impose_lateral_cons_bcs);
BL_PROFILE_VAR("impose_vertical_cons_bcs()",impose_vertical_cons_bcs);
const auto& dom_lo = lbound(domain);
const auto& dom_hi = ubound(domain);

Expand Down
2 changes: 1 addition & 1 deletion Source/BoundaryConditions/ERF_FillPatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ ERF::FillIntermediatePatch (int lev, Real time,
mapper = &cell_cons_interp;
FillPatchTwoLevels(mf, IntVect{ng_cons}, IntVect(0,0,0),
time, cmf, ctime, fmf, ftime,
0, 0, ncomp_cons, geom[lev-1], geom[lev],
icomp_cons, icomp_cons, ncomp_cons, geom[lev-1], geom[lev],
refRatio(lev-1), mapper, domain_bcs_type,
icomp_cons);

Expand Down
19 changes: 13 additions & 6 deletions Source/ERF.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include <AMReX_YAFluxRegister.H>
#include <AMReX_ErrorList.H>

#ifdef ERF_USE_FFT
#include <AMReX_FFT_Poisson.H>
#endif

#ifdef AMREX_MEM_PROFILING
#include <AMReX_MemProfiler.H>
#endif
Expand Down Expand Up @@ -144,8 +148,6 @@ public:

// Project the velocities to be divergence-free -- this is only relevant if anelastic == 1
void project_velocities (int lev, amrex::Real dt, amrex::Vector<amrex::MultiFab >& vars, amrex::MultiFab& p);
void solve_with_heffte (int lev, amrex::MultiFab& rhs, amrex::MultiFab& soln,
amrex::Array<amrex::MultiFab,AMREX_SPACEDIM>& fluxes);

// Project the velocities to be divergence-free with a thin body
void project_velocities_tb (int lev, amrex::Real dt, amrex::Vector<amrex::MultiFab >& vars, amrex::MultiFab& p);
Expand Down Expand Up @@ -376,9 +378,10 @@ public:
// Advance a block specified number of time steps
void Evolve_MB (int MBstep, int max_block_step);

// get the current time values
amrex::Real get_t_old() {return t_old[0];}
amrex::Real get_t_new() {return t_new[0];}
// get the current time values and dt
amrex::Real get_t_old (int lev) { return t_old[lev]; }
amrex::Real get_t_new (int lev) { return t_new[lev]; }
amrex::Real get_dt (int lev) { return dt[lev]; }

// Set parmparse prefix for MultiBlock
void SetParmParsePrefix (std::string name) { pp_prefix = name; }
Expand Down Expand Up @@ -954,7 +957,7 @@ private:

static int verbose;
static int mg_verbose;
static bool use_heffte;
static bool use_fft;

// Diagnostic output interval
static int sum_interval;
Expand Down Expand Up @@ -1307,6 +1310,10 @@ private:
{ return 4; }
#endif

#ifdef ERF_USE_FFT
std::unique_ptr<amrex::FFT::PoissonHybrid<amrex::MultiFab>> m_poisson;
#endif

public:
void writeJobInfo (const std::string& dir) const;
static void writeBuildInfo (std::ostream& os);
Expand Down
4 changes: 2 additions & 2 deletions Source/ERF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int ERF::fixed_mri_dt_ratio = 0;
// Dictate verbosity in screen output
int ERF::verbose = 0;
int ERF::mg_verbose = 0;
bool ERF::use_heffte = false;
bool ERF::use_fft = false;

// Frequency of diagnostic output
int ERF::sum_interval = -1;
Expand Down Expand Up @@ -1401,7 +1401,7 @@ ERF::ReadParameters ()
// Verbosity
pp.query("v", verbose);
pp.query("mg_v", mg_verbose);
pp.query("use_heffte", use_heffte);
pp.query("use_fft", use_fft);

// Frequency of diagnostic output
pp.query("sum_interval", sum_interval);
Expand Down
4 changes: 4 additions & 0 deletions Source/TimeIntegration/ERF_MRI.H
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ public:
nsubsteps = 1; dtau = timestep;
} else {
nsubsteps = substep_ratio; dtau = sub_timestep;

// STRT HACK -- this hack can be used to approximate the no-substepping algorithm
// nsubsteps = 1; dtau = timestep;
// END HACK
}
time_stage = time + timestep;
}
Expand Down
9 changes: 6 additions & 3 deletions Source/TimeIntegration/ERF_TI_fast_headers.H
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ void erf_fast_rhs_N (int step, int nrk, int level, int finest_level,
std::unique_ptr<amrex::MultiFab>& mapfac_v,
amrex::YAFluxRegister* fr_as_crse,
amrex::YAFluxRegister* fr_as_fine,
bool l_use_moisture, bool l_reflux);
bool l_use_moisture, bool l_reflux,
bool l_implicit_substepping);

/**
* Function for computing the fast RHS with fixed terrain
Expand All @@ -64,7 +65,8 @@ void erf_fast_rhs_T (int step, int nrk, int level, int finest_level,
std::unique_ptr<amrex::MultiFab>& mapfac_v,
amrex::YAFluxRegister* fr_as_crse,
amrex::YAFluxRegister* fr_as_fine,
bool l_use_moisture, bool l_reflux);
bool l_use_moisture, bool l_reflux,
bool l_implicit_substepping);

/**
* Function for computing the fast RHS with moving terrain
Expand Down Expand Up @@ -98,7 +100,8 @@ void erf_fast_rhs_MT (int step, int nrk, int level, int finest_level,
std::unique_ptr<amrex::MultiFab>& mapfac_v,
amrex::YAFluxRegister* fr_as_crse,
amrex::YAFluxRegister* fr_as_fine,
bool l_use_moisture, bool l_reflux);
bool l_use_moisture, bool l_reflux,
bool l_implicit_substepping);

/**
* Function for computing the coefficients for the tridiagonal solver used in the fast
Expand Down
28 changes: 19 additions & 9 deletions Source/TimeIntegration/ERF_TI_fast_rhs_fun.H
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ auto fast_rhs_fun = [&](int fast_step, int /*n_sub*/, int nrk,
// Per p2902 of Klemp-Skamarock-Dudhia-2007
// beta_s = -1.0 : fully explicit
// beta_s = 1.0 : fully implicit
Real beta_s = 0.1;
Real beta_s;
if (solverChoice.substepping_type[level] == SubsteppingType::Implicit)
{
beta_s = 0.1;
} else { // Fully explicit
beta_s = -1.0;
}

// *************************************************************************
// Set up flux registers if using two_way coupling
Expand Down Expand Up @@ -99,7 +105,7 @@ auto fast_rhs_fun = [&](int fast_step, int /*n_sub*/, int nrk,
detJ_cc[level], detJ_cc_new[level], detJ_cc_src[level],
dtau, beta_s, inv_fac,
mapfac_m[level], mapfac_u[level], mapfac_v[level],
fr_as_crse, fr_as_fine, l_use_moisture, l_reflux);
fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
} else {
// If this is not the first substep we pass in S_data as the previous step's solution
erf_fast_rhs_MT(fast_step, nrk, level, finest_level,
Expand All @@ -111,7 +117,7 @@ auto fast_rhs_fun = [&](int fast_step, int /*n_sub*/, int nrk,
detJ_cc[level], detJ_cc_new[level], detJ_cc_src[level],
dtau, beta_s, inv_fac,
mapfac_m[level], mapfac_u[level], mapfac_v[level],
fr_as_crse, fr_as_fine, l_use_moisture, l_reflux);
fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
}
} else if (solverChoice.use_terrain && solverChoice.terrain_type == TerrainType::Static) {
if (fast_step == 0) {
Expand All @@ -122,20 +128,22 @@ auto fast_rhs_fun = [&](int fast_step, int /*n_sub*/, int nrk,
detJ_cc[level], r0, pi0, dtau, beta_s, phys_bc_type);

// If this is the first substep we pass in S_old as the previous step's solution
// and S_data is the new-time solution to be defined here
erf_fast_rhs_T(fast_step, nrk, level, finest_level,
S_slow_rhs, S_old, S_stage, S_prim, pi_stage, fast_coeffs,
S_data, S_scratch, fine_geom, solverChoice.gravity, Omega,
z_phys_nd[level], detJ_cc[level], dtau, beta_s, inv_fac,
mapfac_m[level], mapfac_u[level], mapfac_v[level],
fr_as_crse, fr_as_fine, l_use_moisture, l_reflux);
fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
} else {
// If this is not the first substep we pass in S_data as the previous step's solution
// If this is not the first substep we pass in S_data as both the previous step's solution
// and as the new-time solution to be defined here
erf_fast_rhs_T(fast_step, nrk, level, finest_level,
S_slow_rhs, S_data, S_stage, S_prim, pi_stage, fast_coeffs,
S_data, S_scratch, fine_geom, solverChoice.gravity, Omega,
z_phys_nd[level], detJ_cc[level], dtau, beta_s, inv_fac,
mapfac_m[level], mapfac_u[level], mapfac_v[level],
fr_as_crse, fr_as_fine, l_use_moisture, l_reflux);
fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
}
} else {
if (fast_step == 0) {
Expand All @@ -146,20 +154,22 @@ auto fast_rhs_fun = [&](int fast_step, int /*n_sub*/, int nrk,
detJ_cc[level], r0, pi0, dtau, beta_s, phys_bc_type);

// If this is the first substep we pass in S_old as the previous step's solution
// and S_data is the new-time solution to be defined here
erf_fast_rhs_N(fast_step, nrk, level, finest_level,
S_slow_rhs, S_old, S_stage, S_prim, pi_stage, fast_coeffs,
S_data, S_scratch, fine_geom, solverChoice.gravity,
dtau, beta_s, inv_fac,
mapfac_m[level], mapfac_u[level], mapfac_v[level],
fr_as_crse, fr_as_fine, l_use_moisture, l_reflux);
fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
} else {
// If this is not the first substep we pass in S_data as the previous step's solution
// If this is not the first substep we pass in S_data as both the previous step's solution
// and as the new-time solution to be defined here
erf_fast_rhs_N(fast_step, nrk, level, finest_level,
S_slow_rhs, S_data, S_stage, S_prim, pi_stage, fast_coeffs,
S_data, S_scratch, fine_geom, solverChoice.gravity,
dtau, beta_s, inv_fac,
mapfac_m[level], mapfac_u[level], mapfac_v[level],
fr_as_crse, fr_as_fine, l_use_moisture, l_reflux);
fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
}
}

Expand Down
1 change: 1 addition & 0 deletions Source/TimeIntegration/ERF_advance_dycore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ void ERF::advance_dycore(int level,
bool l_use_kturb = ( (tc.les_type != LESType::None) ||
(tc.pbl_type != PBLType::None) );
bool l_use_moisture = ( solverChoice.moisture_type != MoistureType::None );
bool l_implicit_substepping = ( solverChoice.substepping_type[level] == SubsteppingType::Implicit );

const bool use_most = (m_most != nullptr);
const bool exp_most = (solverChoice.use_explicit_most);
Expand Down
Loading

0 comments on commit 8363787

Please sign in to comment.