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