Block-Structured AMR Software Framework
AMReX_EB2_IF_Extrusion.H
Go to the documentation of this file.
1 #ifndef AMREX_EB2_IF_EXTRUSION_H_
2 #define AMREX_EB2_IF_EXTRUSION_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  ExtrusionIF (F a_f, int direction)
20  : m_f(std::move(a_f)),
21  m_direction(direction)
22  {}
23 
24  [[nodiscard]] inline Real operator() (const RealArray& p) const
25  {
26  RealArray x = p;
27  x[m_direction] = 0.0;
28  return m_f(x);
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  switch (m_direction)
36  {
37  case 0:
38  return m_f(AMREX_D_DECL(0.0, y, z));
39  case 1:
40  return m_f(AMREX_D_DECL(x, 0.0, z));
41  default:
42  return m_f(AMREX_D_DECL(x, y, 0.0));
43  }
44  }
45 
46 protected:
47 
48  F m_f;
50 };
51 
52 template <class F>
53 struct IsGPUable<ExtrusionIF<F>, std::enable_if_t<IsGPUable<F>::value>>
54  : std::true_type {};
55 
56 template <class F>
58 extrude (F&&f, int direction)
59 {
60  return ExtrusionIF<std::decay_t<F>>(std::forward<F>(f),direction);
61 }
62 
63 }
64 
65 #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_Extrusion.H:16
Real operator()(const RealArray &p) const
Definition: AMReX_EB2_IF_Extrusion.H:24
F m_f
Definition: AMReX_EB2_IF_Extrusion.H:48
int m_direction
Definition: AMReX_EB2_IF_Extrusion.H:49
ExtrusionIF(F a_f, int direction)
Definition: AMReX_EB2_IF_Extrusion.H:19
Definition: AMReX_FabArrayBase.H:32
constexpr ExtrusionIF< std::decay_t< F > > extrude(F &&f, int direction)
Definition: AMReX_EB2_IF_Extrusion.H:58
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