Block-Structured AMR Software Framework
AMReX_EB2_IF_Torus.H
Go to the documentation of this file.
1 #ifndef AMREX_EB2_IF_TORUS_H_
2 #define AMREX_EB2_IF_TORUS_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_EB2_IF_Base.H>
6 #include <AMReX_Array.H>
7 #include <cmath>
8 
9 // For all implicit functions, >0: body; =0: boundary; <0: fluid
10 
11 namespace amrex::EB2 {
12 
13 class TorusIF
14  : GPUable
15 {
16 public:
17 
18  // inside: is the fluid inside the sphere?
19  TorusIF (Real a_large_radius, Real a_small_radius, const RealArray& a_center, bool a_inside)
20  : m_large_radius(a_large_radius),
21  m_small_radius(a_small_radius),
22  m_center(makeXDim3(a_center)),
23  m_sign( a_inside ? 1.0 : -1.0 )
24  {}
25 
26  [[nodiscard]] AMREX_GPU_HOST_DEVICE inline
27  Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept {
28  Real d = std::hypot(x-m_center.x, y-m_center.y);
29 #if (AMREX_SPACEDIM == 2)
30  return m_sign*((m_large_radius-d)*(m_large_radius-d)
32 #else
33  return m_sign*((m_large_radius-d)*(m_large_radius-d)
34  +(z-m_center.z)*(z-m_center.z)
36 #endif
37  }
38 
39  [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept {
40  return this->operator()(AMREX_D_DECL(p[0],p[1],p[2]));
41  }
42 
43 protected:
44 
48  Real m_sign;
49 };
50 
51 }
52 
53 #endif
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
#define AMREX_D_DECL(a, b, c)
Definition: AMReX_SPACE.H:104
Definition: AMReX_EB2_IF_Torus.H:15
XDim3 m_center
Definition: AMReX_EB2_IF_Torus.H:47
AMREX_GPU_HOST_DEVICE Real operator()(AMREX_D_DECL(Real x, Real y, Real z)) const noexcept
Definition: AMReX_EB2_IF_Torus.H:27
Real m_sign
Definition: AMReX_EB2_IF_Torus.H:48
Real m_small_radius
Definition: AMReX_EB2_IF_Torus.H:46
Real m_large_radius
Definition: AMReX_EB2_IF_Torus.H:45
TorusIF(Real a_large_radius, Real a_small_radius, const RealArray &a_center, bool a_inside)
Definition: AMReX_EB2_IF_Torus.H:19
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