Block-Structured AMR Software Framework
AMReX_EB2_IF_Scale.H
Go to the documentation of this file.
1 #ifndef AMREX_EB2_IF_SCALE_H_
2 #define AMREX_EB2_IF_SCALE_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>
15 class ScaleIF
16 {
17 public:
18 
19  ScaleIF (F a_f, const RealArray& a_scalefactor)
20  : m_f(std::move(a_f)),
21 #if (AMREX_SPACEDIM == 3)
22  m_sfinv{1.0_rt/a_scalefactor[0], 1.0_rt/a_scalefactor[1], 1.0_rt/a_scalefactor[2]}
23 #else
24  m_sfinv{1.0_rt/a_scalefactor[0], 1.0_rt/a_scalefactor[1], 0.0_rt}
25 #endif
26  {}
27 
28  template <class U=F, std::enable_if_t<IsGPUable<U>::value,int> = 0>
29  [[nodiscard]] AMREX_GPU_HOST_DEVICE inline
30  Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept
31  {
32  return m_f(AMREX_D_DECL(x*m_sfinv.x,
33  y*m_sfinv.y,
34  z*m_sfinv.z));
35  }
36 
37  [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept
38  {
39  return m_f({AMREX_D_DECL(p[0]*m_sfinv.x,
40  p[1]*m_sfinv.y,
41  p[2]*m_sfinv.z)});
42  }
43 
44 protected:
45 
46  F m_f;
48 };
49 
50 template <class F>
51 struct IsGPUable<ScaleIF<F>, std::enable_if_t<IsGPUable<F>::value>>
52  : std::true_type {};
53 
54 template <class F>
55 constexpr ScaleIF<std::decay_t<F>>
56 scale (F&&f, const RealArray& scalefactor)
57 {
58  return ScaleIF<std::decay_t<F>>(std::forward<F>(f),scalefactor);
59 }
60 
61 }
62 
63 #endif
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
#define AMREX_D_DECL(a, b, c)
Definition: AMReX_SPACE.H:104
if(!(yy_init))
Definition: amrex_iparser.lex.nolint.H:935
Definition: AMReX_EB2_IF_Scale.H:16
F m_f
Definition: AMReX_EB2_IF_Scale.H:46
ScaleIF(F a_f, const RealArray &a_scalefactor)
Definition: AMReX_EB2_IF_Scale.H:19
AMREX_GPU_HOST_DEVICE Real operator()(AMREX_D_DECL(Real x, Real y, Real z)) const noexcept
Definition: AMReX_EB2_IF_Scale.H:30
XDim3 m_sfinv
Definition: AMReX_EB2_IF_Scale.H:47
Definition: AMReX_FabArrayBase.H:32
constexpr ScaleIF< std::decay_t< F > > scale(F &&f, const RealArray &scalefactor)
Definition: AMReX_EB2_IF_Scale.H:56
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: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