Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
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
16// For all implicit functions, >0: body; =0: boundary; <0: fluid
17
18namespace amrex::EB2 {
19
20template <class F>
23{
24public:
25
27 ScaleIF (F a_f, const RealArray& a_scalefactor)
28 : m_f(std::move(a_f)),
29#if (AMREX_SPACEDIM == 3)
30 m_sfinv{1.0_rt/a_scalefactor[0], 1.0_rt/a_scalefactor[1], 1.0_rt/a_scalefactor[2]}
31#else
32 m_sfinv{1.0_rt/a_scalefactor[0], 1.0_rt/a_scalefactor[1], 0.0_rt}
33#endif
34 {}
35
36 template <class U=F, std::enable_if_t<IsGPUable<U>::value,int> = 0>
39 {
40 return m_f(AMREX_D_DECL(x*m_sfinv.x,
41 y*m_sfinv.y,
42 z*m_sfinv.z));
43 }
44
45 [[nodiscard]] AMREX_FORCE_INLINE Real operator() (const RealArray& p) const noexcept
46 {
47 return m_f({AMREX_D_DECL(p[0]*m_sfinv.x,
48 p[1]*m_sfinv.y,
49 p[2]*m_sfinv.z)});
50 }
51
52protected:
53
56};
57
58template <class F>
59struct IsGPUable<ScaleIF<F>, std::enable_if_t<IsGPUable<F>::value>>
60 : std::true_type {};
61
62template <class F>
64scale (F&&f, const RealArray& scalefactor)
65{
66 return ScaleIF<std::decay_t<F>>(std::forward<F>(f),scalefactor);
67}
68
69}
70
71#endif
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
Scale an implicit function by arbitrary per-axis factors.
Definition AMReX_EB2_IF_Scale.H:23
F m_f
Definition AMReX_EB2_IF_Scale.H:54
__host__ __device__ Real operator()(Real x, Real y, Real z) const noexcept
Definition AMReX_EB2_IF_Scale.H:38
ScaleIF(F a_f, const RealArray &a_scalefactor)
Construct with the child implicit function and scaling factors.
Definition AMReX_EB2_IF_Scale.H:27
XDim3 m_sfinv
Definition AMReX_EB2_IF_Scale.H:55
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
Definition AMReX_FabArrayBase.H:33
constexpr ScaleIF< std::decay_t< F > > scale(F &&f, const RealArray &scalefactor)
Definition AMReX_EB2_IF_Scale.H:64
Array< Real, 3 > RealArray
Definition AMReX_Array.H:28
Type trait that reports whether a functor derives from GPUable.
Definition AMReX_EB2_IF_Base.H:24
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