Block-Structured AMR Software Framework
AMReX_EB2_IF_Sphere.H
Go to the documentation of this file.
1 #ifndef AMREX_EB2_IF_SPHERE_H_
2 #define AMREX_EB2_IF_SPHERE_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 
12 class SphereIF
13  : public GPUable
14 {
15 public:
16 
17  // inside: is the fluid inside the sphere?
18  SphereIF (Real a_radius, const RealArray& a_center, bool a_inside)
19  : m_radius(a_radius),
20  m_center(makeXDim3(a_center)),
21  m_sign( a_inside ? 1.0 : -1.0 )
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),
27  + (y-m_center.y)*(y-m_center.y),
28  + (z-m_center.z)*(z-m_center.z));
29  return m_sign*(d2-m_radius*m_radius);
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 
38  Real m_radius;
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_Sphere.H:14
AMREX_GPU_HOST_DEVICE Real operator()(AMREX_D_DECL(Real x, Real y, Real z)) const noexcept
Definition: AMReX_EB2_IF_Sphere.H:25
Real m_radius
Definition: AMReX_EB2_IF_Sphere.H:38
XDim3 m_center
Definition: AMReX_EB2_IF_Sphere.H:39
SphereIF(Real a_radius, const RealArray &a_center, bool a_inside)
Definition: AMReX_EB2_IF_Sphere.H:18
Real m_sign
Definition: AMReX_EB2_IF_Sphere.H:41
Definition: AMReX_FabArrayBase.H:32
XDim3 makeXDim3(const Array< Real, AMREX_SPACEDIM > &a) noexcept
Definition: AMReX_Array.H:896
Array< Real, AMREX_SPACEDIM > RealArray
Definition: AMReX_Array.H:25
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