ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
erf_earth_wind Namespace Reference

Functions

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void grid_to_earth (amrex::Real u, amrex::Real v, amrex::Real cos_alpha, amrex::Real sin_alpha, amrex::Real &u_east, amrex::Real &v_north) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void earth_to_grid (amrex::Real u_east, amrex::Real v_north, amrex::Real cos_alpha, amrex::Real sin_alpha, amrex::Real &u, amrex::Real &v) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real horizontal_speed (amrex::Real u_east, amrex::Real v_north) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real meteorological_direction (amrex::Real u_east, amrex::Real v_north, amrex::Real missing_value) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void grid_rotation_at (const amrex::Array4< const amrex::Real > &ll, int ilo, int ihi, int i, int j, amrex::Real &cos_alpha, amrex::Real &sin_alpha) noexcept
 

Function Documentation

◆ earth_to_grid()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_earth_wind::earth_to_grid ( amrex::Real  u_east,
amrex::Real  v_north,
amrex::Real  cos_alpha,
amrex::Real  sin_alpha,
amrex::Real &  u,
amrex::Real &  v 
)
noexcept
42 {
43  u = u_east * cos_alpha + v_north * sin_alpha;
44  v = -u_east * sin_alpha + v_north * cos_alpha;
45 }

Referenced by erf_detail_SurfaceLayer::fill_face_current().

Here is the caller graph for this function:

◆ grid_rotation_at()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_earth_wind::grid_rotation_at ( const amrex::Array4< const amrex::Real > &  ll,
int  ilo,
int  ihi,
int  i,
int  j,
amrex::Real &  cos_alpha,
amrex::Real &  sin_alpha 
)
noexcept
87 {
88  const int im = (i - 1 > ilo) ? i - 1 : ilo;
89  const int ip = (i + 1 < ihi) ? i + 1 : ihi;
90  const amrex::Real inv_di = (ip > im) ? amrex::Real(1.0) / amrex::Real(ip - im)
91  : amrex::Real(0.0);
92 
93  // Displacement on the sphere per cell in i: east and north components, in
94  // degrees of latitude (the common factor, the Earth's radius, cancels).
95  // The longitude difference is taken the short way round the antimeridian.
96  amrex::Real dlon = ll(ip,j,0,1) - ll(im,j,0,1);
97  if (dlon > amrex::Real(180.0)) { dlon -= amrex::Real(360.0); }
98  if (dlon < -amrex::Real(180.0)) { dlon += amrex::Real(360.0); }
99  const amrex::Real lat = ll(i,j,0,0);
100  const amrex::Real north = (ll(ip,j,0,0) - ll(im,j,0,0)) * inv_di;
101  const amrex::Real east = dlon * inv_di * std::cos(lat * PI / amrex::Real(180.0));
102  const amrex::Real norm = std::sqrt(east*east + north*north);
103 
104  if (norm > amrex::Real(0.0)) {
105  cos_alpha = east / norm;
106  sin_alpha = north / norm;
107  } else {
108  cos_alpha = amrex::Real(1.0);
109  sin_alpha = amrex::Real(0.0);
110  }
111 }
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:46
Definition: ERF_ConsoleIO.cpp:17

Referenced by fill_grid_rotation(), and grid_rotation_from_latlon().

Here is the caller graph for this function:

◆ grid_to_earth()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_earth_wind::grid_to_earth ( amrex::Real  u,
amrex::Real  v,
amrex::Real  cos_alpha,
amrex::Real  sin_alpha,
amrex::Real &  u_east,
amrex::Real &  v_north 
)
noexcept
32 {
33  u_east = u * cos_alpha - v * sin_alpha;
34  v_north = u * sin_alpha + v * cos_alpha;
35 }

Referenced by plotfile2d::erf_detail_Plotfile2DInterpolator::earth_wind_at_cell_center(), near_surface_diagnostics::fill_wind_10m(), erf_detail_to_REMORA::FillEastNorth(), and ERF::sample_stations().

Here is the caller graph for this function:

◆ horizontal_speed()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_earth_wind::horizontal_speed ( amrex::Real  u_east,
amrex::Real  v_north 
)
noexcept
49 {
50  return std::sqrt(u_east * u_east + v_north * v_north);
51 }

Referenced by plotfile2d::erf_detail_Plotfile2DInterpolator::horizontal_wind_speed(), meteorological_direction(), and ERF::sample_stations().

Here is the caller graph for this function:

◆ meteorological_direction()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_earth_wind::meteorological_direction ( amrex::Real  u_east,
amrex::Real  v_north,
amrex::Real  missing_value 
)
noexcept
62 {
63  if (horizontal_speed(u_east, v_north) <= amrex::Real(1.0e-12)) {
64  return missing_value;
65  }
66  amrex::Real direction = amrex::Real(270.0)
67  - std::atan2(v_north, u_east) * amrex::Real(180.0) / PI;
68  while (direction < amrex::Real(0.0)) {
69  direction += amrex::Real(360.0);
70  }
71  while (direction >= amrex::Real(360.0)) {
72  direction -= amrex::Real(360.0);
73  }
74  return direction;
75 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real horizontal_speed(amrex::Real u_east, amrex::Real v_north) noexcept
Definition: ERF_EarthRelativeWind.H:48

Referenced by plotfile2d::erf_detail_Plotfile2DInterpolator::meteorological_wind_direction(), and ERF::sample_stations().

Here is the call graph for this function:
Here is the caller graph for this function: