ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TerrainIF Class Reference

#include <ERF_EBIFTerrain.H>

Inheritance diagram for TerrainIF:
Collaboration diagram for TerrainIF:

Public Member Functions

 TerrainIF (amrex::FArrayBox const &a_z_terrain, amrex::Geometry const &a_geom, amrex::Gpu::DeviceVector< amrex::Real > &a_dz_stretched)
 
AMREX_GPU_HOST_DEVICE amrex::Real operator() (AMREX_D_DECL(amrex::Real x, amrex::Real y, amrex::Real z)) const noexcept
 
AMREX_GPU_HOST_DEVICE amrex::Real operator() (const amrex::RealArray &p) const noexcept
 

Protected Attributes

amrex::Array4< amrex::Real const > terr_arr
 
amrex::Real const * dz_s
 
amrex::Real dx
 
amrex::Real dy
 
amrex::Real dz
 
amrex::Real prob_lo_x
 
amrex::Real prob_lo_y
 
amrex::Real prob_lo_z
 
amrex::Real prob_hi_x
 
amrex::Real prob_hi_y
 
int i_hi
 
int j_hi
 

Constructor & Destructor Documentation

◆ TerrainIF()

TerrainIF::TerrainIF ( amrex::FArrayBox const &  a_z_terrain,
amrex::Geometry const &  a_geom,
amrex::Gpu::DeviceVector< amrex::Real > &  a_dz_stretched 
)
inline
19  : terr_arr(a_z_terrain.const_array()),
20  dz_s(a_dz_stretched.data()),
21  dx(a_geom.CellSize(0)),
22  dy(a_geom.CellSize(1)),
23  dz(a_geom.CellSize(2)),
24  prob_lo_x(a_geom.ProbLo(0)),
25  prob_lo_y(a_geom.ProbLo(1)),
26  prob_lo_z(a_geom.ProbLo(2)),
27  prob_hi_x(a_geom.ProbHi(0)),
28  prob_hi_y(a_geom.ProbHi(1)),
29  i_hi(static_cast<int>(std::round((a_geom.ProbHi(0)-a_geom.ProbLo(0))/a_geom.CellSize(0)))),
30  j_hi(static_cast<int>(std::round((a_geom.ProbHi(1)-a_geom.ProbLo(1))/a_geom.CellSize(1))))
31  {}
amrex::Real prob_lo_x
Definition: ERF_EBIFTerrain.H:124
amrex::Real dy
Definition: ERF_EBIFTerrain.H:123
int j_hi
Definition: ERF_EBIFTerrain.H:126
amrex::Array4< amrex::Real const > terr_arr
Definition: ERF_EBIFTerrain.H:121
amrex::Real prob_hi_x
Definition: ERF_EBIFTerrain.H:125
amrex::Real const * dz_s
Definition: ERF_EBIFTerrain.H:122
amrex::Real prob_lo_y
Definition: ERF_EBIFTerrain.H:124
amrex::Real dx
Definition: ERF_EBIFTerrain.H:123
amrex::Real prob_lo_z
Definition: ERF_EBIFTerrain.H:124
int i_hi
Definition: ERF_EBIFTerrain.H:126
amrex::Real dz
Definition: ERF_EBIFTerrain.H:123
amrex::Real prob_hi_y
Definition: ERF_EBIFTerrain.H:125

Member Function Documentation

◆ operator()() [1/2]

AMREX_GPU_HOST_DEVICE amrex::Real TerrainIF::operator() ( AMREX_D_DECL(amrex::Real x, amrex::Real y, amrex::Real z ) const
inlinenoexcept
36  {
37  int i1{};
38  int j1{};
39  int i2{};
40  int j2{};
41 
42  amrex::Real x1{};
43  amrex::Real x2{};
44  amrex::Real y1{};
45  amrex::Real y2{};
46  amrex::Real w1{};
47  amrex::Real w2{};
48  amrex::Real terr_z{0.};
49 
50  // z_stretched
51  const int k1 = static_cast<int>(std::floor((z-prob_lo_z) / dz));
52  const amrex::Real z1 = prob_lo_z + k1*dz;
53  const amrex::Real remainder_z = (z - z1)/dz;
54  amrex::Real z_stretched = prob_lo_z;
55  for (int kk = 0; kk < k1; ++kk) {
56  z_stretched += dz_s[kk];
57  }
58  z_stretched += remainder_z * dz_s[k1];
59 
60  // Interpolation (nine subregions of x-y plane)
61  if (x <= prob_lo_x && y <= prob_lo_y) {
62  terr_z = terr_arr(0 ,0 ,0);
63  } else if (x >= prob_hi_x && y <= prob_lo_y) {
64  terr_z = terr_arr(i_hi,0 ,0);
65  } else if (x >= prob_hi_x && y >= prob_hi_y) {
66  terr_z = terr_arr(i_hi,j_hi,0);
67  } else if (x <= prob_lo_x && y >= prob_hi_y) {
68  terr_z = terr_arr(0 ,j_hi,0);
69  } else if (x > prob_lo_x && x < prob_hi_x && (y <= prob_lo_y || y >= prob_hi_y) ) {
70  i1 = static_cast<int>(std::floor((x-prob_lo_x) / dx));
71  i2 = i1+1;
72  x1 = prob_lo_x + i1*dx;
73  x2 = x1 + dx;
74  w1 = (x2-x)/dx;
75  w2 = (x-x1)/dx;
76  if (y <= prob_lo_y){
77  terr_z = w1*terr_arr(i1,0 ,0) + w2*terr_arr(i2,0 ,0);
78  } else if (y >= prob_hi_y) {
79  terr_z = w1*terr_arr(i1,j_hi,0) + w2*terr_arr(i2,j_hi,0);
80  }
81  } else if (y > prob_lo_y && y < prob_hi_y && (x <= prob_lo_x || x >= prob_hi_x) ) {
82  j1 = static_cast<int>(std::floor((y-prob_lo_y) / dy));
83  j2 = j1+1;
84  y1 = prob_lo_y + j1*dy;
85  y2 = y1 + dy;
86  w1 = (y2-y)/dy;
87  w2 = (y-y1)/dy;
88  if (x <= prob_lo_x){
89  terr_z = w1*terr_arr(0 ,j1,0) + w2*terr_arr(0 ,j2,0);
90  } else if (x >= prob_hi_x) {
91  terr_z = w1*terr_arr(i_hi,j1,0) + w2*terr_arr(i_hi,j2,0);
92  }
93  } else {
94  // Do bilinear interpolation of the terrain surface
95  i1 = static_cast<int>(std::floor((x-prob_lo_x) / dx));
96  i2 = i1+1;
97  j1 = static_cast<int>(std::floor((y-prob_lo_y) / dy));
98  j2 = j1+1;
99  x1 = prob_lo_x + i1*dx;
100  x2 = x1 + dx;
101  y1 = prob_lo_y + j1*dy;
102  y2 = y1 + dy;
103 
104  const amrex::Real denom = dx*dy;
105  const amrex::Real w11 = (x2-x)*(y2-y)/denom;
106  const amrex::Real w12 = (x2-x)*(y-y1)/denom;
107  const amrex::Real w21 = (x-x1)*(y2-y)/denom;
108  const amrex::Real w22 = (x-x1)*(y-y1)/denom;
109  terr_z = w11*terr_arr(i1,j1,0) + w12*terr_arr(i1,j2,0) + w21*terr_arr(i2,j1,0) + w22*terr_arr(i2,j2,0);
110  }
111  return -(z_stretched - terr_z);
112  }

Referenced by operator()().

Here is the caller graph for this function:

◆ operator()() [2/2]

AMREX_GPU_HOST_DEVICE amrex::Real TerrainIF::operator() ( const amrex::RealArray &  p) const
inlinenoexcept
116  {
117  return this->operator() (AMREX_D_DECL(p[0], p[1], p[2]));
118  }
AMREX_GPU_HOST_DEVICE amrex::Real operator()(AMREX_D_DECL(amrex::Real x, amrex::Real y, amrex::Real z)) const noexcept
Definition: ERF_EBIFTerrain.H:34
Here is the call graph for this function:

Member Data Documentation

◆ dx

amrex::Real TerrainIF::dx
protected

Referenced by operator()().

◆ dy

amrex::Real TerrainIF::dy
protected

Referenced by operator()().

◆ dz

amrex::Real TerrainIF::dz
protected

Referenced by operator()().

◆ dz_s

amrex::Real const* TerrainIF::dz_s
protected

Referenced by operator()().

◆ i_hi

int TerrainIF::i_hi
protected

Referenced by operator()().

◆ j_hi

int TerrainIF::j_hi
protected

Referenced by operator()().

◆ prob_hi_x

amrex::Real TerrainIF::prob_hi_x
protected

Referenced by operator()().

◆ prob_hi_y

amrex::Real TerrainIF::prob_hi_y
protected

Referenced by operator()().

◆ prob_lo_x

amrex::Real TerrainIF::prob_lo_x
protected

Referenced by operator()().

◆ prob_lo_y

amrex::Real TerrainIF::prob_lo_y
protected

Referenced by operator()().

◆ prob_lo_z

amrex::Real TerrainIF::prob_lo_z
protected

Referenced by operator()().

◆ terr_arr

amrex::Array4<amrex::Real const> TerrainIF::terr_arr
protected

Referenced by operator()().


The documentation for this class was generated from the following file: