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