ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_Plotfile2DInterpolator.H
Go to the documentation of this file.
1 #ifndef ERF_PLOTFILE2DINTERPOLATOR_H_
2 #define ERF_PLOTFILE2DINTERPOLATOR_H_
3 
4 #include <AMReX_MultiFab.H>
5 #include <AMReX_GpuQualifiers.H>
6 #include <AMReX_REAL.H>
7 
9 
10 // Vertical sampling helpers for ERF 2D plotfiles. These helpers copy model
11 // levels or linearly interpolate cell-centered fields onto one target level.
12 // The 2D writer calls this layer after it allocates output components.
13 
14 namespace plotfile2d
15 {
16 
18 {
19  int klo = -1;
20  int khi = -1;
21  bool found = false;
22 };
23 
25 {
26  const amrex::MultiFab* xvel = nullptr;
27  const amrex::MultiFab* yvel = nullptr;
28  const amrex::MultiFab* zvel = nullptr;
29  const amrex::MultiFab* cos_alpha = nullptr;
30  const amrex::MultiFab* sin_alpha = nullptr;
31 };
32 
33 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
35  amrex::Real c0,
36  amrex::Real c1) noexcept
37 {
38  return (c0 <= target && target <= c1) ||
39  (c1 <= target && target <= c0);
40 }
41 
42 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
44  amrex::Real hi_value,
45  amrex::Real lo_coord,
46  amrex::Real hi_coord,
47  amrex::Real target) noexcept
48 {
49  if (hi_coord == lo_coord) {
50  return lo_value;
51  }
52 
53  const amrex::Real weight = (target - lo_coord) / (hi_coord - lo_coord);
54  return lo_value + weight * (hi_value - lo_value);
55 }
56 
57 void fill_sampled_level_component (amrex::MultiFab& dst,
58  int dst_comp,
60  const amrex::MultiFab& cons,
61  const amrex::MultiFab* z_phys_cc,
62  const amrex::MultiFab& z_phys_nd,
63  bool have_z_phys_cc,
64  const MoistureComponentIndices& moisture_indices,
65  int klo,
66  int khi,
67  const SampledWindSources& wind_sources = {});
68 
69 } // namespace plotfile2d
70 
71 #endif
const int khi
Definition: ERF_InitCustomPert_Bubble.H:21
DiagnosticDescriptor descriptor
Definition: ERF_Plotfile2DCatalog.cpp:100
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ cons
Definition: ERF_IndexDefines.H:175
real(c_double), private c1
Definition: ERF_module_mp_morr_two_moment.F90:212
Definition: ERF_Plotfile2DCatalog.cpp:7
void fill_sampled_level_component(MultiFab &dst, int dst_comp, const Plotfile2DOutputDescriptor &descriptor, const MultiFab &cons, const MultiFab *z_phys_cc, const MultiFab &z_phys_nd, bool have_z_phys_cc, const MoistureComponentIndices &moisture_indices, int klo, int khi, const SampledWindSources &wind_sources)
Definition: ERF_Plotfile2DInterpolator.cpp:167
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real linear_interpolate(amrex::Real lo_value, amrex::Real hi_value, amrex::Real lo_coord, amrex::Real hi_coord, amrex::Real target) noexcept
Definition: ERF_Plotfile2DInterpolator.H:43
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:34
Definition: ERF_DataStruct.H:106
Definition: ERF_Plotfile2DSampledLevel.H:53
Definition: ERF_Plotfile2DInterpolator.H:18
int khi
Definition: ERF_Plotfile2DInterpolator.H:20
bool found
Definition: ERF_Plotfile2DInterpolator.H:21
int klo
Definition: ERF_Plotfile2DInterpolator.H:19
Definition: ERF_Plotfile2DInterpolator.H:25
const amrex::MultiFab * sin_alpha
Definition: ERF_Plotfile2DInterpolator.H:30
const amrex::MultiFab * xvel
Definition: ERF_Plotfile2DInterpolator.H:26
const amrex::MultiFab * cos_alpha
Definition: ERF_Plotfile2DInterpolator.H:29
const amrex::MultiFab * zvel
Definition: ERF_Plotfile2DInterpolator.H:28
const amrex::MultiFab * yvel
Definition: ERF_Plotfile2DInterpolator.H:27