.. _wci:

***********************
Wave-averaged Equations
***********************

=============== ============================================================
MRL_WCI         Activate wave-current interactions
MRL_CEW         Activate current effect on waves (2-way interaction)
ANA_WWAVE       Analytical (constant) wave parameters (Hs,Tp,Dir)
WAVE_OFFLINE    Activate wave forcing from offline model/data
WKB_WWAVE       Activate CROCO's monochromatic (WKB) model
OW_COUPLING     Activate coupling with spectral wave model (WW3)
WAVE_FRICTION   Activate bottom friction for WKB model and WAVE_STREAMING
WAVE_STREAMING  Activate bottom streaming (needs WAVE_FRICTION)
STOKES_DRIFT    Activate Stokes drift
=============== ============================================================

*Preselected options:*
::

# define STOKES_DRIFT

A vortex-force formalism for the interaction of surface gravity waves and currents 
is implemented in CROCO :cite:p:`marchesiello_tridimensional_2015,uchiyama_wavecurrent_2010`. 
Eulerian wave-averaged current equations for mass, momentum, and tracers are included 
based on an asymptotic theory by :cite:t:`mcwilliams_asymptotic_2004` plus 
non-conservative wave effects due to wave breaking, associated surface roller 
waves, bottom streaming, and wave-enhanced vertical mixing and bottom drag especially 
for coastal and nearshore applications. The wave information is provided by either a 
spectrum-peak WKB wave-refraction model that includes the effect of currents on waves, or, 
alternatively, a spectrum-resolving wave model (e.g., WAVEWATCH3) can be used. In nearshore 
applications, the currents’ cross-shore and vertical structure is shaped by the wave effects 
of near-surface breaker acceleration, vertical component of vortex force, and wave-enhanced 
pressure force and bottom drag.

Equations in Cartesian coordinates
----------------------------------

In the Eulerian wave-averaged current equations, terms for the wave effect 
on currents (WEC) are added to the primitive equations. Three new variables are defined:

.. math::

  \xi^c & = \xi + \hat{\xi}

  \phi^c & = \phi + \hat{\phi}

  \vec{\textbf v}_L & = \vec{\textbf v} + \vec{\textbf v}_S

where :math:`\xi^c` is a composite sea level,  :math:`\phi^c` absorbs the 
Bernoulli head :math:`\hat{\phi}`, :math:`\vec{\textbf v_L}` is the wave-averaged 
Lagrangian velocity, sum of Eulerian velocity and Stokes drift :math:`\vec{\textbf v_S}`. 
The 3D Stokes velocity is non-divergent and defined for a monochromatic wave field 
(amplitude A, wavenumber vector :math:`\vec{\textbf k}=(k_x,k_y)`, and frequency :math:`\sigma`) by:

.. math::

  u_S & = \frac{A^2 \sigma}{2 \sinh^2 \left ( k D \right ) } \cosh \left ( 2 k (z+h) \right ) k_x

  v_S & = \frac{A^2 \sigma}{2 \sinh^2 \left ( k D \right ) } \cosh \left ( 2 k (z+h) \right ) k_y

  w_S & = - \int_{-h}^{z} \left (  \frac{\partial u_S}{\partial x} 
                                 + \frac{\partial v_S}{\partial y}\right ) ~dz' 

Where :math:`D=h+\xi^c`. The quasi-static sea level and Bernouilli head are:

.. math::

  \hat{\xi}  & = - \frac{A^2 k}{2 \sinh \left ( 2 k D \right ) }

  \hat{\phi} & = \frac{A^2 \sigma}{4 k \sinh^2 \left ( k D \right ) }
                 \int_{-h}^{z} \frac{\partial^2 \vec{\textbf k}.\vec{\textbf v} }
                                    {\partial z'^2}  \sinh \left ( 2 k (z-z') \right ) ~dz'


The primitive equations become (after re-organizing advection and vortex force terms):

.. math::

  \frac{\partial u}{\partial t}
   + \vec{\bf \nabla} . \left ( \vec{\textbf v}_L u \right ) - f v_L  & =
   - \frac{\partial \phi^c}{\partial x}  
   + \left ( u_S \frac{\partial u}{\partial x} + v_S \frac{\partial v}{\partial x} \right )
   + \mathcal{F}_u +  \mathcal{D}_u + \mathcal{F^W}_u

  \frac{\partial v}{\partial t} 
   + \vec{\bf \nabla} . \left ( \vec{\textbf v}_L v \right ) + f u_L & = 
   - \frac{\partial \phi^c}{\partial y}  
   + \left ( u_S \frac{\partial u}{\partial y} + v_S \frac{\partial v}{\partial y} \right )
   + \mathcal{F}_v +  \mathcal{D}_v + \mathcal{F^W}_v

  \frac{\partial \phi^c}{\partial z} + \frac{\rho g}{\rho_0} & = 
     \vec{\textbf v}_S. \frac{\partial \vec{\textbf v}}{\partial z}

    \frac{\partial C}{\partial t} 
      + \vec{\bf \nabla} . \left ( \vec{\textbf v}_L C \right ) & =
        \mathcal{F}_C +  \mathcal{D}_C + \mathcal{F^W}_C

      \vec{\bf \nabla} . \vec{\textbf v}_L & = 0

   \rho & = \rho(T,S,P)



The variables used are :

:math:`\mathcal{D}_u, \mathcal{D}_v, \mathcal{D}_C` : diffusive terms (including wave-enhaced bottom drag and mixing)

:math:`\mathcal{F}_u, \mathcal{F}_v, \mathcal{F}_C` : forcing terms

:math:`\mathcal{F^W}_u, \mathcal{F^W}_v, \mathcal{F^W}_C` : wave forcing terms (bottom streaming, breaking acceleration)

:math:`f(x,y)` : Traditional Coriolis parameter :math:`2 \Omega sin \phi`

:math:`g` : acceleration of gravity

:math:`\phi(x,y,z,t)` : dynamic pressure :math:`\phi=P/\rho_0`, with P the total pressure

:math:`\rho_0+\rho(x,y,z,t)` : total in situ density

:math:`u,v,w` : the (x,y,z) components of vector velocity :math:`\vec{\textbf v}`


Embedded wave model
-------------------

================= ====================================================================
WKB_WWAVE         Activate WKB wave model
WAVE_ROLLER       Activate wave rollers
WAVE_FRICTION     Activate bottom friction
WKB_ADD_DIFF      Activate additional diffusion to wave number field
MRL_CEW           Active current effect on waves
WKB_KZ_FILTER     Activate space filter on ubar, vbar, zeta for CEW
WKB_TIME_FILTER   Activate time  filter on ubar, vbar, zeta for CEW
WAVE_RAMP         Activate wave ramp
ANA_BRY_WKB       Read boundary data from croco.in
WKB_OBC_WEST      Offshore wave forcing at the western boundary
WKB_OBC_EAST      Offshore wave forcing at the eastern boundary
================= ====================================================================

*Preselected options:*
::

# ifdef MRL_CEW
#  undef  WKB_KZ_FILTER
#  undef  WKB_TIME_FILTER
# endif
# define WKB_ADD_DIFF
# if defined SHOREFACE || defined SANDBAR || (defined RIP && !defined BISCA)
#  define ANA_BRY_WKB
# endif


A WKB wave model for monochromatic waves is embedded in CROCO 
following :cite:t:`uchiyama_wavecurrent_2010`. It is based on the 
conservation of wave action :math:`\mathcal{A} = E/\sigma` and 
wavenumber :math:`\textbf k` -- wave crest conservation -- and 
is particularly suitable for nearshore beach applications, 
allowing refraction from bathymetry and currents (but no diffraction 
or reflection), with parametrizations for wave breaking and bottom drag:

.. math::

    \frac{\partial \mathcal{A}}{\partial t} 
        + \vec{\bf \nabla} . \mathcal{A} \vec{\bf c}_g = -\frac{\epsilon^w}{\sigma}

          \frac{\partial \vec{\bf k}}{\partial t}
        + \vec{\bf c}_g . {\bf \nabla} \vec{\bf k} = 
        - \vec{\bf k}   . {\bf \nabla} \vec{\bf V} 
        - \frac{k\sigma}{\sinh 2kD} {\bf \nabla} D

:math:`\vec{\bf V}` is the depth-averaged velocity vector and :math:`\sigma` 
is the intrinsic frequency defined by the linear dispersion 
relation :math:`\sigma^2 = gk \tanh kD`. Current effects on waves are noticeable in 
the groupe velocity :math:`c_g` which gets two components: the doppler shift due to 
currents on waves and the groupe velocity of the primary carrier waves : 

.. math::

        \vec{\bf c}_g = \vec{\bf V}  + \frac{\sigma}{2k^2} 
                        \left ( 1+\frac{2kD}{\sinh 2kD} \right ) \vec{\textbf k}

The currents may need filtering before entering the wave model equations because 
the current field should evolve slowly with respect to waves in the asymptotic 
regime described by :cite:t:`mcwilliams_asymptotic_2004`. By default, this filtering 
is turned off (WKB_KZ_FILTER, WKB_TIME_FILTER).

:math:`\epsilon^w` is the depth-integrated rate of wave energy dissipation due to 
depth-induced breaking :math:`\epsilon^b` (including white capping) and bottom 
friction :math:`\epsilon^{wd}`, both of which must be parameterized (in WKB, WW3 
or CROCO if defined WAVE_OFFLINE):

 .. math::

     \epsilon^w = \epsilon^b + \epsilon^{wd}

Breaking acceleration and bottom streaming
------------------------------------------

A formulation for :math:`\epsilon^{b}` is needed in both the wave model (dissipation 
term) and the circulation model (acceleration term). In the wave-averaged momentum 
equations of the circulation model, the breaking acceleration enters as a body 
force through :math:`\mathcal{F^W}`:

.. math::

  \vec{\bf F^b} = \frac{\epsilon^b}{\rho \sigma} \vec{\bf k} ~f_b(z)

where :math:`f_b(z)` is a normalized vertical distribution function representing 
vertical penetration of momentum associated with breaking waves from the surface. 
The penetration depth is controlled by a vertical length-scale taken as :math:`H_{rms}`.

The wave model can also include a roller model with dissipation :math:`\epsilon^r`. 
In this case:

.. math::

  \vec{\bf F^b} = \frac{(1-\alpha_r)\epsilon^b+\epsilon^r}{\rho \sigma} \vec{\bf k} ~f_b(z)

The idea is that some fraction :math:`\alpha_r` of wave energy is converted into 
rollers that propagate toward the shoreline before dissipating, while the remaining 
fraction :math:`1-\alpha_r` causes local dissipation (hence current acceleration). 
It can be useful for correcting :math:`\epsilon^b` with some flexibility to depict 
different breaking wave and beach forms (e.g., spilling or plunging breakers, barred 
or plane beaches), although the parameter :math:`B_b` can also be used for that. 
See :cite:t:`uchiyama_wavecurrent_2010` for the roller equation and :math:`\epsilon^r` formulation.

Wave-enhanced bottom dissipation enters in the momentum equations through a combined 
wave-current drag formulation (see parametrizations) and bottom streaming. The latter 
is due to dissipation of wave energy in the wave boundary layer that causes the 
instantaneous, oscillatory wave bottom orbital velocities to be slightly in phase from 
quadrature; this causes a wave stress (bottom streaming) in the wave bottom boundary layer 
along the direction of wave propagation :cite:p:`longuet-higgins_mass_1953`. The effect of 
bottom streaming in momentum balance is accounted for by using the wave dissipation due to 
bottom friction with an upward decaying vertical distribution:

.. math::

  \vec{\bf F^{st}} = \frac{\epsilon^{wd}}{\rho \sigma} \vec{\bf k} ~f_{st}(z)

where :math:`f_{st}(z)` is a vertical distribution function.

Formulation of wave energy dissipation
--------------------------------------

================= ====================================================================
WAVE_SFC_BREAK    Activate surface breaking acceleration
WAVE_BREAK_CT93   Activate :cite:t:`church_effects_1993` breaking acceleration (default)
WAVE_BREAK_TG86   Activate :cite:t:`thornton_transformation_1983,thornton_surf_1986`
================= ====================================================================

*Preselected options:*
::

# define WAVE_BREAK_CT93
# undef  WAVE_BREAK_TG86
# undef  WAVE_SFC_BREAK

While a few formulations for :math:`\epsilon^b` are implemented in CROCO, the one 
by :cite:t:`church_effects_1993` is generally successful for nearshore beach applications: 

.. math::
        \epsilon^b = \frac{3}{16} \sqrt{\pi} \rho g B^3_b \frac{H^3_{rms}}{D}
    \left \{ 1 + \tanh \left [ 8   \left ( \frac{H_{rms}}{\gamma_b D} -1 \right ) \right ] \right \}
    \left \{ 1 -       \left [ 1 + \left ( \frac{H_{rms}}{\gamma_b D} \right )^2 \right ]^{-2.5} \right \}

where :math:`B_b` and :math:`\gamma_b` are empirical parameters related to wave 
breaking. :math:`\gamma_b` represents the wave height-to-depth ratio for which all waves 
are assumed to be breaking and :math:`B_b` is the fraction of foam on the face, accounting 
for the type of breaker. :math:`H_{rms}` is the RMS wave height. For the DUCK94 
experiment, :cite:t:`uchiyama_wavecurrent_2010` suggest :math:`\gamma_b=0.4` and :math:`B_b = 0.8`, 
while for Biscarrosse Beach, :cite:t:`marchesiello_tridimensional_2015` use :math:`\gamma_b=0.3` 
and :math:`B_b = 1.3` from calibration with video cameras.

For :math:`\epsilon^{wd}`, the dissipation caused by bottom viscous drag on the primary waves, 
we use a parameterization for the realistic regime of a turbulent wave boundary layer, 
consistent with the WKB spectrum-peak wave modeling:

.. math::

   \epsilon^{wd} = \frac{1}{2 \sqrt\pi} \rho f_w u^3_{orb}

where :math:`u_{orb}` is the wave orbital velocity magnitude and :math:`f_w` is a wave 
friction factor, function of roughness length :math:`z_0`: 

.. math::

   u_{orb} & = \frac{\sigma H_{rms}}{2 \sinh kD}
   
   f_w & = 1.39 \left ( \frac{\sigma z_0}{u_{orb}} \right ) ^{0.52}
