ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_TerrainIF.H
Go to the documentation of this file.
1 #ifndef ERF_TERRAIN_IF_H_
2 #define ERF_TERRAIN_IF_H_
3 
4 #include <AMReX_Array.H>
5 #include <AMReX_EB2_IF_Base.H>
6 
7 #include <cmath>
8 #include <algorithm>
9 
10 // For all implicit functions, >0: body; =0: boundary; <0: fluid
11 
12 class TerrainIF
13  : amrex::GPUable
14 {
15 public:
16 
17  TerrainIF (amrex::FArrayBox& a_z_terrain, amrex::Geometry& a_geom)
18  : m_terr(a_z_terrain),
19  m_geom(a_geom)
20  {
21  amrex::Print() << " EB type = Terrain " << std::endl;
22  }
23 
24  AMREX_GPU_HOST_DEVICE inline
25  amrex::Real operator() (AMREX_D_DECL(amrex::Real x, amrex::Real y, amrex::Real z))
26  const noexcept
27  {
28  amrex::Real dx = m_geom.CellSizeArray()[0];
29  amrex::Real dy = m_geom.CellSizeArray()[1];
30 
31  const int i = static_cast<int>(x / dx);
32  const int j = static_cast<int>(y / dy);
33 
34  amrex::Array4<amrex::Real const> const& terr_arr = m_terr.const_array();
35 
36  return -(z - terr_arr(i,j,0));
37  }
38 
39  inline amrex::Real operator() (const amrex::RealArray& p) const noexcept
40  {
41  return this->operator() (AMREX_D_DECL(p[0], p[1], p[2]));
42  }
43 
44 protected:
45  amrex::FArrayBox& m_terr;
46  amrex::Geometry& m_geom;
47 };
48 
49 #endif
Definition: ERF_TerrainIF.H:14
amrex::FArrayBox & m_terr
Definition: ERF_TerrainIF.H:45
TerrainIF(amrex::FArrayBox &a_z_terrain, amrex::Geometry &a_geom)
Definition: ERF_TerrainIF.H:17
AMREX_GPU_HOST_DEVICE amrex::Real operator()(AMREX_D_DECL(amrex::Real x, amrex::Real y, amrex::Real z)) const noexcept
Definition: ERF_TerrainIF.H:25
amrex::Geometry & m_geom
Definition: ERF_TerrainIF.H:46