ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
most_aitken Struct Reference

#include <ERF_MOSTUtils.H>

Collaboration diagram for most_aitken:

Public Member Functions

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real update (amrex::Real u_new, int iter)
 

Public Attributes

int start {25}
 
bool extrapolated {false}
 whether the last update returned an extrapolated value More...
 
int n {0}
 
amrex::Real u0 {zero}
 
amrex::Real u1 {zero}
 
amrex::Real u2 {zero}
 

Detailed Description

Aitken delta-squared acceleration of the relaxed u* iteration in the prescribed-flux kernels.

Near the stable fold the slope of the fixed-point map approaches 1 and the plain iteration needs hundreds of passes. From pass start on, every third iterate is replaced by the Aitken extrapolation of the last three (kept only within a factor of 2 of them), so points that converge before start are unchanged. The map is not stationary when w* or a u*-dependent z0 also changes from pass to pass, so the kernels do not stop on an extrapolated pass: the plain pass after it, with zeta and psi from the same u*, decides convergence.

Member Function Documentation

◆ update()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real most_aitken::update ( amrex::Real  u_new,
int  iter 
)
inline

Return the iterate to continue from.

Parameters
[in]u_newiterate after pass iter
[in]iternumber of passes done
718  {
719  extrapolated = false;
720  if (iter < start) { return u_new; }
721  u0 = u1;
722  u1 = u2;
723  u2 = u_new;
724  if (++n < 3) { return u_new; }
725  const amrex::Real d = u2 - two * u1 + u0;
726  const amrex::Real ua = (d != zero) ? u2 - (u2 - u1) * (u2 - u1) / d : u_new;
727  const amrex::Real lo = myhalf * amrex::min(u0, amrex::min(u1, u2));
728  const amrex::Real hi = two * amrex::max(u0, amrex::max(u1, u2));
729  if (d == zero || !(ua > lo && ua < hi)) {
730  n = 0;
731  return u_new;
732  }
733  // The extrapolated value starts the next triple
734  u2 = ua;
735  n = 1;
736  extrapolated = true;
737  return ua;
738  }
constexpr amrex::Real two
Definition: ERF_NumericalConstants.H:38
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
amrex::Real u2
Definition: ERF_MOSTUtils.H:745
int start
Definition: ERF_MOSTUtils.H:740
bool extrapolated
whether the last update returned an extrapolated value
Definition: ERF_MOSTUtils.H:741
int n
Definition: ERF_MOSTUtils.H:742
amrex::Real u0
Definition: ERF_MOSTUtils.H:743
amrex::Real u1
Definition: ERF_MOSTUtils.H:744

Referenced by surface_flux_charnock::iterate_flux(), surface_flux_mod_charnock::iterate_flux(), surface_flux_donelan::iterate_flux(), surface_flux_wave_coupled::iterate_flux(), surface_flux::iterate_flux(), and surface_flux_eb::iterate_flux().

Here is the caller graph for this function:

Member Data Documentation

◆ extrapolated

◆ n

int most_aitken::n {0}

Referenced by update().

◆ start

int most_aitken::start {25}

Referenced by update().

◆ u0

amrex::Real most_aitken::u0 {zero}

Referenced by update().

◆ u1

amrex::Real most_aitken::u1 {zero}

Referenced by update().

◆ u2

amrex::Real most_aitken::u2 {zero}

Referenced by update().


The documentation for this struct was generated from the following file: