Skip to content

Commit

Permalink
Update planar-averaged diagnostic profile output (erf-model#1451)
Browse files Browse the repository at this point in the history
* Add interp_profiles_to_cc option

* Implement staggered output quantities involving vertical flux

* Remove misleading "k" quantity, which was a sum of products of instantaneous fields (u*u + v*v + w*w)--not
fluctuating fields--and therefore not actually "TKE"

* Reformulate triple product for planar averaged profile output

* Add additional amrex debugging option (off by default)

* Update docs for diagnostic profile output
  • Loading branch information
ewquon authored Feb 22, 2024
1 parent a0bb4db commit 8c0620b
Show file tree
Hide file tree
Showing 8 changed files with 791 additions and 49 deletions.
1 change: 1 addition & 0 deletions CMake/BuildERFExe.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ function(build_erf_lib erf_lib_name)
${SRC_DIR}/IO/ERF_ReadBndryPlanes.cpp
${SRC_DIR}/IO/ERF_WriteBndryPlanes.cpp
${SRC_DIR}/IO/ERF_Write1DProfiles.cpp
${SRC_DIR}/IO/ERF_Write1DProfiles_stag.cpp
${SRC_DIR}/IO/ERF_WriteScalarProfiles.cpp
${SRC_DIR}/IO/Plotfile.cpp
${SRC_DIR}/IO/writeJobInfo.cpp
Expand Down
1 change: 1 addition & 0 deletions CMake/SetAmrexOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set(AMReX_HDF5 "${ERF_ENABLE_HDF5}" CACHE STRING "Enable HDF5 support in AMReX"
set(AMReX_ENABLE_TESTS OFF)
set(AMReX_FPE OFF)
set(AMReX_ASSERTIONS OFF)
set(AMReX_BOUND_CHECK OFF)
set(AMReX_BASE_PROFILE OFF)
set(AMReX_TINY_PROFILE ${ERF_ENABLE_TINY_PROFILE})
set(AMReX_TRACE_PROFILE OFF)
Expand Down
131 changes: 131 additions & 0 deletions Docs/sphinx_doc/Inputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,137 @@ Examples of Usage
| for example. If this line is commented out then it will not compute
and print these quantities.
Diagnostic Outputs
==================

If ``erf.v`` is set then one or more additional output files may be requested.
These include (1) a surface time history file, (2) a history of mean profiles,
(3) a history of vertical flux profiles (i.e., variances and covariances), and
(4) a history of modeled subgrid stresses. The number of specified output
filenames dictates the level of output. E.g., specifying 3 filenames will give
outputs (1), (2), and (3). Data files are only written if ``erf.profile_int >
0``. This output functionality has not been implemented for terrain.

.. _list-of-parameters-10a:


List of Parameters
------------------

+-------------------------------+------------------+----------------+----------------+
| Parameter | Definition | Acceptable | Default |
| | | Values | |
+===============================+==================+================+================+
| **erf.datalog** | Output | Up to four | NONE |
| | filename(s) | strings | |
+-------------------------------+------------------+----------------+----------------+
| **erf.profile_int** | Interval (number)| Integer | -1 |
| | of steps between | | |
| | ouputs | | |
+-------------------------------+------------------+----------------+----------------+
| **erf.interp_profiles_to_cc** | Interpolate all | Boolean | true |
| | outputs to cell | | |
| | centers | | |
+-------------------------------+------------------+----------------+----------------+

By default, all profiles are planar-averaged quantities :math:`\langle\cdot\rangle`
interpolated to cell centers. Setting ``erf.interp_profiles_to_cc = false`` will
keep vertically staggered quantities on z faces (quantities already at cell
centers or on x/y faces will remain at those locations). Note that all output
quantities--whether cell-centered or face-centered--will be output on the
staggered grid. The user should discard the highest z level (corresponding to
the z-dir ``amr.n_cell`` + 1) for cell-centered quantities. Staggered quantities
are indicated below.

The requested output files have the following columns:


* Surface time history

#. Time (s)

#. Friction velocity, :math:`u_*` (m/s)

#. Surface-layer potential temperature scale, :math:`\theta_*` (K)

#. Obukhov length, :math:`L` (m)

* Mean flow profiles

#. Time (s)

#. Height (m)

#. X-velocity, :math:`\langle u \rangle` (m/s)

#. Y-velocity, :math:`\langle v \rangle` (m/s)

#. *Z-velocity*, :math:`\langle w \rangle` (m/s) -- *staggered*

#. Dry air density, :math:`\langle \rho \rangle` (kg/m3)

#. Total (moist) potential temperature, :math:`\langle \theta \rangle` (K)

#. Turbulent kinetic energy (TKE), :math:`\langle k \rangle` (m2/s2) for the subgrid model

* Vertical flux profiles

#. Time (s)

#. Height (m)

#. X-velocity variance, :math:`\langle u^\prime u^\prime \rangle` (m2/s2)

#. X,Y-velocity covariance, :math:`\langle u^\prime v^\prime \rangle` (m2/s2)

#. *X,Z-velocity covariance*, :math:`\langle u^\prime w^\prime \rangle` (m2/s2) -- *staggered*

#. Y-velocity variance, :math:`\langle v^\prime v^\prime \rangle` (m2/s2)

#. *Y,Z-velocity covariance*, :math:`\langle v^\prime w^\prime \rangle` (m2/s2) -- *staggered*

#. *Z-velocity variance*, :math:`\langle w^\prime w^\prime \rangle` (m2/s2) -- *staggered*

#. X-direction heat flux, :math:`\langle u^\prime \theta^\prime \rangle` (K m/s)

#. Y-direction heat flux, :math:`\langle v^\prime \theta^\prime \rangle` (K m/s)

#. *Z-direction heat flux*, :math:`\langle w^\prime \theta^\prime \rangle` (K m/s) -- *staggered*

#. Temperature variance, :math:`\langle \theta^\prime \theta^\prime \rangle` (K m/s)

#. X-direction turbulent transport of TKE, :math:`\langle u_i^\prime u_i^\prime u^\prime \rangle` (m3/s3)
-- Note: :math:`u_i u_i = uu + vv + ww`

#. Y-direction turbulent transport of TKE, :math:`\langle u_i^\prime u_i^\prime v^\prime \rangle` (m3/s3)

#. *Z-direction turbulent transport of TKE*, :math:`\langle u_i^\prime u_i^\prime w^\prime \rangle` (m3/s3) -- *staggered*

#. X-direction pressure transport of TKE, :math:`\langle p^\prime u^\prime \rangle` (m3/s3)

#. Y-direction pressure transport of TKE, :math:`\langle p^\prime v^\prime \rangle` (m3/s3)

#. *Z-direction pressure transport of TKE*, :math:`\langle p^\prime w^\prime \rangle` (m3/s3) -- *staggered*

* Modeled subgrid-scale (SGS) profiles

#. SGS stress tensor component, :math:`\tau_{11}` (m2/s2)

#. SGS stress tensor component, :math:`\tau_{12}` (m2/s2)

#. *SGS stress tensor component*, :math:`\tau_{13}` (m2/s2) -- *staggered*

#. SGS stress tensor component, :math:`\tau_{22}` (m2/s2)

#. *SGS stress tensor component*, :math:`\tau_{23}` (m2/s2) -- *staggered*

#. SGS stress tensor component, :math:`\tau_{33}` (m2/s2)

#. SGS heat flux, :math:`\tau_{\theta w}` (K m/s)

#. SGS turbulence dissipation, :math:`\epsilon` (m2/s3)


Advection Schemes
=================

Expand Down
21 changes: 20 additions & 1 deletion Source/ERF.H
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public:
// Diagnostics
void sum_integrated_quantities (amrex::Real time);
void write_1D_profiles (amrex::Real time);
void write_1D_profiles_stag (amrex::Real time);

void sample_points (int lev, amrex::Real time, amrex::IntVect cell, amrex::MultiFab& mf);
void sample_lines (int lev, amrex::Real time, amrex::IntVect cell, amrex::MultiFab& mf);
Expand All @@ -157,17 +158,34 @@ public:
amrex::Gpu::HostVector<amrex::Real>& h_avg_ww,
amrex::Gpu::HostVector<amrex::Real>& h_avg_uth , amrex::Gpu::HostVector<amrex::Real>& h_avg_vth,
amrex::Gpu::HostVector<amrex::Real>& h_avg_wth, amrex::Gpu::HostVector<amrex::Real>& h_avg_thth,
amrex::Gpu::HostVector<amrex::Real>& h_avg_k,
amrex::Gpu::HostVector<amrex::Real>& h_avg_ku, amrex::Gpu::HostVector<amrex::Real>& h_avg_kv,
amrex::Gpu::HostVector<amrex::Real>& h_avg_kw,
amrex::Gpu::HostVector<amrex::Real>& h_avg_p,
amrex::Gpu::HostVector<amrex::Real>& h_avg_pu, amrex::Gpu::HostVector<amrex::Real>& h_avg_pv,
amrex::Gpu::HostVector<amrex::Real>& h_avg_pw);
void derive_diag_profiles_stag (amrex::Gpu::HostVector<amrex::Real>& h_avg_u , amrex::Gpu::HostVector<amrex::Real>& h_avg_v ,
amrex::Gpu::HostVector<amrex::Real>& h_avg_w , amrex::Gpu::HostVector<amrex::Real>& h_avg_rho,
amrex::Gpu::HostVector<amrex::Real>& h_avg_th , amrex::Gpu::HostVector<amrex::Real>& h_avg_ksgs,
amrex::Gpu::HostVector<amrex::Real>& h_avg_uu , amrex::Gpu::HostVector<amrex::Real>& h_avg_uv ,
amrex::Gpu::HostVector<amrex::Real>& h_avg_uw,
amrex::Gpu::HostVector<amrex::Real>& h_avg_vv , amrex::Gpu::HostVector<amrex::Real>& h_avg_vw ,
amrex::Gpu::HostVector<amrex::Real>& h_avg_ww,
amrex::Gpu::HostVector<amrex::Real>& h_avg_uth , amrex::Gpu::HostVector<amrex::Real>& h_avg_vth,
amrex::Gpu::HostVector<amrex::Real>& h_avg_wth, amrex::Gpu::HostVector<amrex::Real>& h_avg_thth,
amrex::Gpu::HostVector<amrex::Real>& h_avg_ku, amrex::Gpu::HostVector<amrex::Real>& h_avg_kv,
amrex::Gpu::HostVector<amrex::Real>& h_avg_kw,
amrex::Gpu::HostVector<amrex::Real>& h_avg_p,
amrex::Gpu::HostVector<amrex::Real>& h_avg_pu, amrex::Gpu::HostVector<amrex::Real>& h_avg_pv,
amrex::Gpu::HostVector<amrex::Real>& h_avg_pw);

void derive_stress_profiles (amrex::Gpu::HostVector<amrex::Real>& h_avg_tau11, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau12,
amrex::Gpu::HostVector<amrex::Real>& h_avg_tau13, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau22,
amrex::Gpu::HostVector<amrex::Real>& h_avg_tau23, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau33,
amrex::Gpu::HostVector<amrex::Real>& h_avg_hfx3, amrex::Gpu::HostVector<amrex::Real>& h_avg_diss);
void derive_stress_profiles_stag (amrex::Gpu::HostVector<amrex::Real>& h_avg_tau11, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau12,
amrex::Gpu::HostVector<amrex::Real>& h_avg_tau13, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau22,
amrex::Gpu::HostVector<amrex::Real>& h_avg_tau23, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau33,
amrex::Gpu::HostVector<amrex::Real>& h_avg_hfx3, amrex::Gpu::HostVector<amrex::Real>& h_avg_diss);

// Perform the volume-weighted sum
amrex::Real
Expand Down Expand Up @@ -657,6 +675,7 @@ private:

// other sampling output control
int profile_int = -1;
bool cc_profiles = true;

// Checkpoint type, prefix and frequency
std::string check_file {"chk"};
Expand Down
17 changes: 15 additions & 2 deletions Source/ERF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,13 @@ ERF::post_timestep (int nstep, Real time, Real dt_lev0)
}

if (profile_int > 0 && (nstep+1) % profile_int == 0) {
write_1D_profiles(time);
if (cc_profiles) {
// all variables cell-centered
write_1D_profiles(time);
} else {
// some variables staggered
write_1D_profiles_stag(time);
}
}

if (output_1d_column) {
Expand Down Expand Up @@ -683,7 +689,13 @@ ERF::InitData ()

if (is_it_time_for_action(istep[0], t_new[0], dt[0], sum_interval, sum_per)) {
sum_integrated_quantities(t_new[0]);
write_1D_profiles(t_new[0]);
if (cc_profiles) {
// all variables cell-centered
write_1D_profiles(t_new[0]);
} else {
// some variables staggered
write_1D_profiles_stag(t_new[0]);
}
}

// We only write the file at level 0 for now
Expand Down Expand Up @@ -1129,6 +1141,7 @@ ERF::ReadParameters ()
}

pp.query("profile_int", profile_int);
pp.query("interp_profiles_to_cc", cc_profiles);

pp.query("plot_lsm", plot_lsm);

Expand Down
Loading

0 comments on commit 8c0620b

Please sign in to comment.