Block-Structured AMR Software Framework
AMReX_EB2_IF_Box.H
Go to the documentation of this file.
1 #ifndef AMREX_EB2_IF_BOX_H_
2 #define AMREX_EB2_IF_BOX_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_Array.H>
6 #include <AMReX_EB2_IF_Base.H>
7 
8 #include <algorithm>
9 #include <limits>
10 
11 // For all implicit functions, >0: body; =0: boundary; <0: fluid
12 
13 namespace amrex::EB2 {
14 
15 class BoxIF
16  : GPUable
17 {
18 public:
19 
21  BoxIF (const RealArray& a_lo, const RealArray& a_hi, bool a_inside)
22  : m_lo(makeXDim3(a_lo)),
23  m_hi(makeXDim3(a_hi)),
24  m_sign( a_inside ? 1.0 : -1.0 )
25  {}
26 
27  [[nodiscard]] AMREX_GPU_HOST_DEVICE inline
28  Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept
29  {
30  Real r = std::numeric_limits<Real>::lowest();
31  AMREX_D_TERM(r = amrex::max(r, x-m_hi.x, -(x-m_lo.x));,
32  r = amrex::max(r, y-m_hi.y, -(y-m_lo.y));,
33  r = amrex::max(r, z-m_hi.z, -(z-m_lo.z)););
34  return r*m_sign;
35  }
36 
37  [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept
38  {
39  return this->operator() (AMREX_D_DECL(p[0], p[1], p[2]));
40  }
41 
42 protected:
43 
46  //
47  Real m_sign;
48 };
49 
50 }
51 
52 #endif
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
#define AMREX_D_TERM(a, b, c)
Definition: AMReX_SPACE.H:129
#define AMREX_D_DECL(a, b, c)
Definition: AMReX_SPACE.H:104
Definition: AMReX_EB2_IF_Box.H:17
XDim3 m_hi
Definition: AMReX_EB2_IF_Box.H:45
XDim3 m_lo
Definition: AMReX_EB2_IF_Box.H:44
Real m_sign
Definition: AMReX_EB2_IF_Box.H:47
BoxIF(const RealArray &a_lo, const RealArray &a_hi, bool a_inside)
inside: is the fluid inside the box?
Definition: AMReX_EB2_IF_Box.H:21
AMREX_GPU_HOST_DEVICE Real operator()(AMREX_D_DECL(Real x, Real y, Real z)) const noexcept
Definition: AMReX_EB2_IF_Box.H:28
Definition: AMReX_FabArrayBase.H:32
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const T & max(const T &a, const T &b) noexcept
Definition: AMReX_Algorithm.H:35
XDim3 makeXDim3(const Array< Real, AMREX_SPACEDIM > &a) noexcept
Definition: AMReX_Array.H:885
Array< Real, AMREX_SPACEDIM > RealArray
Definition: AMReX_Array.H:26
Definition: AMReX_EB2_IF_Base.H:11
Definition: AMReX_Dim3.H:13
Real x
Definition: AMReX_Dim3.H:13
Real z
Definition: AMReX_Dim3.H:13
Real y
Definition: AMReX_Dim3.H:13