Block-Structured AMR Software Framework
AMReX_EB2_IF_Ellipsoid.H
Go to the documentation of this file.
1 #ifndef AMREX_EB2_IF_ELLIPSOID_H_
2 #define AMREX_EB2_IF_ELLIPSOID_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_Array.H>
6 #include <AMReX_EB2_IF_Base.H>
7 
8 // For all implicit functions, >0: body; =0: boundary; <0: fluid
9 
10 namespace amrex::EB2 {
11 
13  : public GPUable
14 {
15 public:
16 
17  // inside: is the fluid inside the ellipsoid?
18  EllipsoidIF (const RealArray& a_radii, const RealArray& a_center, bool a_inside)
19  : m_radii(makeXDim3(a_radii)),
20  m_center(makeXDim3(a_center)),
21  m_sign( a_inside ? 1.0_rt : -1.0_rt )
22  {}
23 
24  [[nodiscard]] AMREX_GPU_HOST_DEVICE inline
25  Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept {
26  Real d2 = AMREX_D_TERM( (x-m_center.x)*(x-m_center.x) / (m_radii.x*m_radii.x),
27  + (y-m_center.y)*(y-m_center.y) / (m_radii.y*m_radii.y),
28  + (z-m_center.z)*(z-m_center.z) / (m_radii.z*m_radii.z));
29  return m_sign*(d2-1.0_rt);
30  }
31 
32  [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept {
33  return this->operator()(AMREX_D_DECL(p[0],p[1],p[2]));
34  }
35 
36 protected:
37 
40  //
41  Real m_sign;
42 };
43 
44 }
45 
46 #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_Ellipsoid.H:14
EllipsoidIF(const RealArray &a_radii, const RealArray &a_center, bool a_inside)
Definition: AMReX_EB2_IF_Ellipsoid.H:18
XDim3 m_radii
Definition: AMReX_EB2_IF_Ellipsoid.H:38
Real m_sign
Definition: AMReX_EB2_IF_Ellipsoid.H:41
XDim3 m_center
Definition: AMReX_EB2_IF_Ellipsoid.H:39
AMREX_GPU_HOST_DEVICE Real operator()(AMREX_D_DECL(Real x, Real y, Real z)) const noexcept
Definition: AMReX_EB2_IF_Ellipsoid.H:25
Definition: AMReX_FabArrayBase.H:32
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