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 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

◆ 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
77 {
78  const int im = (i - 1 > ilo) ? i - 1 : ilo;
79  const int ip = (i + 1 < ihi) ? i + 1 : ihi;
80  const amrex::Real inv_di = (ip > im) ? amrex::Real(1.0) / amrex::Real(ip - im)
81  : amrex::Real(0.0);
82 
83  // Displacement on the sphere per cell in i: east and north components, in
84  // degrees of latitude (the common factor, the Earth's radius, cancels).
85  // The longitude difference is taken the short way round the antimeridian.
86  amrex::Real dlon = ll(ip,j,0,1) - ll(im,j,0,1);
87  if (dlon > amrex::Real(180.0)) { dlon -= amrex::Real(360.0); }
88  if (dlon < -amrex::Real(180.0)) { dlon += amrex::Real(360.0); }
89  const amrex::Real lat = ll(i,j,0,0);
90  const amrex::Real north = (ll(ip,j,0,0) - ll(im,j,0,0)) * inv_di;
91  const amrex::Real east = dlon * inv_di * std::cos(lat * PI / amrex::Real(180.0));
92  const amrex::Real norm = std::sqrt(east*east + north*north);
93 
94  if (norm > amrex::Real(0.0)) {
95  cos_alpha = east / norm;
96  sin_alpha = north / norm;
97  } else {
98  cos_alpha = amrex::Real(1.0);
99  sin_alpha = amrex::Real(0.0);
100  }
101 }
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:46
Real sin_alpha
Definition: ERF_Plotfile2DInterpolator.cpp:29
Real cos_alpha
Definition: ERF_Plotfile2DInterpolator.cpp:28
amrex::Real Real
Definition: ERF_ShocInterface.H:19
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 }
Real u_east
Definition: ERF_Plotfile2DInterpolator.cpp:21
Real v_north
Definition: ERF_Plotfile2DInterpolator.cpp:22

Referenced by near_surface_diagnostics::fill_wind_10m(), 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
39 {
40  return std::sqrt(u_east * u_east + v_north * v_north);
41 }

Referenced by 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
52 {
53  if (horizontal_speed(u_east, v_north) <= amrex::Real(1.0e-12)) {
54  return missing_value;
55  }
56  amrex::Real direction = amrex::Real(270.0)
57  - std::atan2(v_north, u_east) * amrex::Real(180.0) / PI;
58  while (direction < amrex::Real(0.0)) {
59  direction += amrex::Real(360.0);
60  }
61  while (direction >= amrex::Real(360.0)) {
62  direction -= amrex::Real(360.0);
63  }
64  return direction;
65 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real horizontal_speed(amrex::Real u_east, amrex::Real v_north) noexcept
Definition: ERF_EarthRelativeWind.H:38

Referenced by ERF::sample_stations().

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