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

Classes

struct  SampledEarthWind
 
struct  SampledRotation
 

Functions

AMREX_GPU_DEVICE AMREX_FORCE_INLINE SampledRotation rotation_at_mass_point (int i, int j, const Array4< const Real > &cos_alpha_arr, const Array4< const Real > &sin_alpha_arr, bool have_rotation) noexcept
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE SampledEarthWind earth_wind_at_cell_center (int i, int j, int k, const Array4< const Real > &xvel_arr, const Array4< const Real > &yvel_arr, const Array4< const Real > &zvel_arr, const Array4< const Real > &cos_alpha_arr, const Array4< const Real > &sin_alpha_arr, bool have_rotation) noexcept
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE Real horizontal_wind_speed (const SampledEarthWind &wind) noexcept
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE Real meteorological_wind_direction (const SampledEarthWind &wind, Real missing_value) noexcept
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE Real wind_field_from_earth_wind (SampledFieldID field_id, const SampledEarthWind &wind, Real missing_value) noexcept
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE SampledBracket find_sampled_bracket (SampledCoordinate coordinate, Real target, int klo, int khi, int i, int j, const Array4< const Real > &cons_arr, const Array4< const Real > &z_phys_cc_arr, const Array4< const Real > &z_phys_nd_arr, const Array4< const Real > &z_sfc_nd_arr, const Array4< const Real > &p_hse_arr, bool have_z_phys_cc, bool use_hse_pressure, const MoistureComponentIndices &moisture_indices) noexcept
 

Function Documentation

◆ earth_wind_at_cell_center()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE SampledEarthWind plotfile2d::erf_detail_Plotfile2DInterpolator::earth_wind_at_cell_center ( int  i,
int  j,
int  k,
const Array4< const Real > &  xvel_arr,
const Array4< const Real > &  yvel_arr,
const Array4< const Real > &  zvel_arr,
const Array4< const Real > &  cos_alpha_arr,
const Array4< const Real > &  sin_alpha_arr,
bool  have_rotation 
)
noexcept
52 {
53  const Real u_cc = Real(0.5) * (xvel_arr(i, j, k) + xvel_arr(i + 1, j, k));
54  const Real v_cc = Real(0.5) * (yvel_arr(i, j, k) + yvel_arr(i, j + 1, k));
55  const Real w_cc = Real(0.5) * (zvel_arr(i, j, k) + zvel_arr(i, j, k + 1));
56 
57  const SampledRotation rot = rotation_at_mass_point(i, j, cos_alpha_arr, sin_alpha_arr,
58  have_rotation);
59 
60  SampledEarthWind wind;
61  erf_earth_wind::grid_to_earth(u_cc, v_cc, rot.cos_alpha, rot.sin_alpha,
62  wind.u_east, wind.v_north);
63  wind.w = w_cc;
64  return wind;
65 }
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
Definition: ERF_EarthRelativeWind.H:29
AMREX_GPU_DEVICE AMREX_FORCE_INLINE SampledRotation rotation_at_mass_point(int i, int j, const Array4< const Real > &cos_alpha_arr, const Array4< const Real > &sin_alpha_arr, bool have_rotation) noexcept
Definition: ERF_Plotfile2DInterpolator.cpp:32

Referenced by plotfile2d::fill_sampled_level_component().

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

◆ find_sampled_bracket()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE SampledBracket plotfile2d::erf_detail_Plotfile2DInterpolator::find_sampled_bracket ( SampledCoordinate  coordinate,
Real  target,
int  klo,
int  khi,
int  i,
int  j,
const Array4< const Real > &  cons_arr,
const Array4< const Real > &  z_phys_cc_arr,
const Array4< const Real > &  z_phys_nd_arr,
const Array4< const Real > &  z_sfc_nd_arr,
const Array4< const Real > &  p_hse_arr,
bool  have_z_phys_cc,
bool  use_hse_pressure,
const MoistureComponentIndices &  moisture_indices 
)
noexcept
112 {
113  SampledBracket bracket;
114  if (khi < klo) {
115  return bracket;
116  }
117 
118  auto coordinate_value = [=] AMREX_GPU_DEVICE (int kk) noexcept -> Real {
119  if (coordinate == SampledCoordinate::ModelIndex) {
120  return static_cast<Real>(kk);
121  }
122 
123  const auto field_id = (coordinate == SampledCoordinate::HeightMSL)
124  ? SampledFieldID::HeightMSL
125  : (coordinate == SampledCoordinate::HeightAGL)
126  ? SampledFieldID::HeightAGL
127  : SampledFieldID::Pressure;
128  return sampled_field_value(field_id, cons_arr, z_phys_cc_arr, z_phys_nd_arr, z_sfc_nd_arr, p_hse_arr,
129  have_z_phys_cc, use_hse_pressure, i, j, kk, moisture_indices);
130  };
131 
132  const Real c0 = coordinate_value(klo);
133  if (target == c0) {
134  bracket.klo = klo;
135  bracket.khi = klo;
136  bracket.found = true;
137  return bracket;
138  }
139 
140  Real lo = c0;
141  for (int k = klo; k < khi; ++k) {
142  const Real hi = coordinate_value(k + 1);
143  if (sampled_target_is_bracketed(target, lo, hi)) {
144  bracket.klo = k;
145  bracket.khi = k + 1;
146  bracket.found = true;
147  return bracket;
148  }
149  lo = hi;
150  }
151 
152  return bracket;
153 }
const int khi
Definition: ERF_InitCustomPert_Bubble.H:25
const int klo
Definition: ERF_InitCustomPert_KE.H:9
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real sampled_field_value(SampledFieldID field_id, const amrex::Array4< const amrex::Real > &cons_arr, const amrex::Array4< const amrex::Real > &z_phys_cc_arr, const amrex::Array4< const amrex::Real > &z_phys_nd_arr, const amrex::Array4< const amrex::Real > &z_sfc_nd_arr, const amrex::Array4< const amrex::Real > &p_hse_arr, bool have_z_phys_cc, bool use_hse_pressure, int i, int j, int k, const MoistureComponentIndices &moisture_indices) noexcept
Definition: ERF_Plotfile2DSampledField.H:96
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool sampled_target_is_bracketed(amrex::Real target, amrex::Real c0, amrex::Real c1) noexcept
Definition: ERF_Plotfile2DInterpolator.H:37

Referenced by plotfile2d::fill_sampled_level_component().

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

◆ horizontal_wind_speed()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE Real plotfile2d::erf_detail_Plotfile2DInterpolator::horizontal_wind_speed ( const SampledEarthWind &  wind)
noexcept
69 {
70  return erf_earth_wind::horizontal_speed(wind.u_east, wind.v_north);
71 }
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 wind_field_from_earth_wind().

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

◆ meteorological_wind_direction()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE Real plotfile2d::erf_detail_Plotfile2DInterpolator::meteorological_wind_direction ( const SampledEarthWind &  wind,
Real  missing_value 
)
noexcept
76 {
77  return erf_earth_wind::meteorological_direction(wind.u_east, wind.v_north, missing_value);
78 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real meteorological_direction(amrex::Real u_east, amrex::Real v_north, amrex::Real missing_value) noexcept
Definition: ERF_EarthRelativeWind.H:60

Referenced by wind_field_from_earth_wind().

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

◆ rotation_at_mass_point()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE SampledRotation plotfile2d::erf_detail_Plotfile2DInterpolator::rotation_at_mass_point ( int  i,
int  j,
const Array4< const Real > &  cos_alpha_arr,
const Array4< const Real > &  sin_alpha_arr,
bool  have_rotation 
)
noexcept
36 {
37  if (!have_rotation) {
38  return {};
39  }
40 
41  return {cos_alpha_arr(i, j, 0), sin_alpha_arr(i, j, 0)};
42 }

Referenced by earth_wind_at_cell_center().

Here is the caller graph for this function:

◆ wind_field_from_earth_wind()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE Real plotfile2d::erf_detail_Plotfile2DInterpolator::wind_field_from_earth_wind ( SampledFieldID  field_id,
const SampledEarthWind &  wind,
Real  missing_value 
)
noexcept
84 {
85  switch (field_id) {
86  case SampledFieldID::UEast: return wind.u_east;
87  case SampledFieldID::VNorth: return wind.v_north;
88  case SampledFieldID::W: return wind.w;
89  case SampledFieldID::WindSpeed: return horizontal_wind_speed(wind);
90  case SampledFieldID::WindDir: return meteorological_wind_direction(wind, missing_value);
91  default: break;
92  }
93  return Real(0.0);
94 }
@ W
Definition: ERF_ObsNudgingSeries.H:36
AMREX_GPU_DEVICE AMREX_FORCE_INLINE Real horizontal_wind_speed(const SampledEarthWind &wind) noexcept
Definition: ERF_Plotfile2DInterpolator.cpp:68
AMREX_GPU_DEVICE AMREX_FORCE_INLINE Real meteorological_wind_direction(const SampledEarthWind &wind, Real missing_value) noexcept
Definition: ERF_Plotfile2DInterpolator.cpp:74

Referenced by plotfile2d::fill_sampled_level_component().

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