Block-Structured AMR Software Framework
AMReX_EB2_IF_Complement.H
Go to the documentation of this file.
1 #ifndef AMREX_EB2_IF_COMPLEMENT_H_
2 #define AMREX_EB2_IF_COMPLEMENT_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 
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  ComplementIF (F a_f) : m_f(std::move(a_f)) {}
20 
21  [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept
22  {
23  return -m_f(p);
24  }
25 
26  template<class U=F, std::enable_if_t<IsGPUable<U>::value,int> = 0>
27  [[nodiscard]] AMREX_GPU_HOST_DEVICE inline
28  Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept
29  {
30  return -m_f(AMREX_D_DECL(x,y,z));
31  }
32 
33 protected:
34 
35  F m_f;
36 };
37 
38 template <class F>
39 struct IsGPUable<ComplementIF<F>, std::enable_if_t<IsGPUable<F>::value>>
40  : std::true_type {};
41 
42 template <class F>
45 {
46  return ComplementIF<std::decay_t<F>>(std::forward<F>(f));
47 }
48 
49 }
50 
51 #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_Complement.H:16
F m_f
Definition: AMReX_EB2_IF_Complement.H:35
Real operator()(const RealArray &p) const noexcept
Definition: AMReX_EB2_IF_Complement.H:21
ComplementIF(F a_f)
Definition: AMReX_EB2_IF_Complement.H:19
Definition: AMReX_FabArrayBase.H:32
constexpr ComplementIF< std::decay_t< F > > makeComplement(F &&f)
Definition: AMReX_EB2_IF_Complement.H:44
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