Block-Structured AMR Software Framework
AMReX_EB2_IF_Lathe.H
Go to the documentation of this file.
1 #ifndef AMREX_EB2_IF_LATHE_H_
2 #define AMREX_EB2_IF_LATHE_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_Array.H>
6 #include <AMReX_EB2_IF_Base.H>
7 
8 #include <type_traits>
9 #include <cmath>
10 
11 // For all implicit functions, >0: body; =0: boundary; <0: fluid
12 
13 namespace amrex::EB2 {
14 
15 template <class F>
16 class LatheIF
17 {
18 public:
19 
20  LatheIF (F a_f) : m_f(std::move(a_f)) {}
21 
22  [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept
23  {
24  Real r = std::hypot(p[0],p[1]);
25 #if (AMREX_SPACEDIM == 2)
26  return m_f({r,0.0});
27 #else
28  return m_f({r,p[2],0.0});
29 #endif
30  }
31 
32  template <class U=F, std::enable_if_t<IsGPUable<U>::value,int> = 0>
33  [[nodiscard]] AMREX_GPU_HOST_DEVICE inline
34  Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept
35  {
36  Real r = std::hypot(x,y);
37 #if (AMREX_SPACEDIM == 2)
38  return m_f(r,0.0);
39 #else
40  return m_f(r,z,0.0);
41 #endif
42  }
43 
44 protected:
45 
46  F m_f;
47 };
48 
49 template <class F>
50 struct IsGPUable<LatheIF<F>, std::enable_if_t<IsGPUable<F>::value>>
51  : std::true_type {};
52 
53 template <class F>
54 constexpr LatheIF<std::decay_t<F>>
55 lathe (F&& f)
56 {
57  return LatheIF<std::decay_t<F>>(std::forward<F>(f));
58 }
59 
60 }
61 
62 #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_Lathe.H:17
LatheIF(F a_f)
Definition: AMReX_EB2_IF_Lathe.H:20
F m_f
Definition: AMReX_EB2_IF_Lathe.H:46
Real operator()(const RealArray &p) const noexcept
Definition: AMReX_EB2_IF_Lathe.H:22
Definition: AMReX_FabArrayBase.H:32
constexpr LatheIF< std::decay_t< F > > lathe(F &&f)
Definition: AMReX_EB2_IF_Lathe.H:55
static int f(amrex::Real t, N_Vector y_data, N_Vector y_rhs, void *user_data)
Definition: AMReX_SundialsIntegrator.H:44
Array< Real, AMREX_SPACEDIM > RealArray
Definition: AMReX_Array.H:25
Definition: AMReX_EB2_IF_Base.H:15