Block-Structured AMR Software Framework
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
AMReX_EB2_IF_Lathe.H
Go to the documentation of this file.
1#ifndef AMREX_EB2_IF_LATHE_H_
2#define AMREX_EB2_IF_LATHE_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#include <cmath>
10
11// For all implicit functions, >0: body; =0: boundary; <0: fluid
12
13namespace amrex::EB2 {
14
15template <class F>
17{
18public:
19
20 LatheIF (F a_f) : m_f(std::move(a_f)) {}
21
22 [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept
23 {
24 Real r = std::hypot(p[0],p[1]);
25#if (AMREX_SPACEDIM == 2)
26 return m_f({r,0.0});
27#else
28 return m_f({r,p[2],0.0});
29#endif
30 }
31
32 template <class U=F, std::enable_if_t<IsGPUable<U>::value,int> = 0>
33 [[nodiscard]] AMREX_GPU_HOST_DEVICE inline
34 Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept
35 {
36 Real r = std::hypot(x,y);
37#if (AMREX_SPACEDIM == 2)
38 return m_f(r,0.0);
39#else
40 return m_f(r,z,0.0);
41#endif
42 }
43
44protected:
45
47};
48
49template <class F>
50struct IsGPUable<LatheIF<F>, std::enable_if_t<IsGPUable<F>::value>>
51 : std::true_type {};
52
53template <class F>
55lathe (F&& f)
56{
57 return LatheIF<std::decay_t<F>>(std::forward<F>(f));
58}
59
60}
61
62#endif
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
Definition AMReX_EB2_IF_Lathe.H:17
LatheIF(F a_f)
Definition AMReX_EB2_IF_Lathe.H:20
F m_f
Definition AMReX_EB2_IF_Lathe.H:46
Real operator()(const RealArray &p) const noexcept
Definition AMReX_EB2_IF_Lathe.H:22
Definition AMReX_FabArrayBase.H:32
constexpr LatheIF< std::decay_t< F > > lathe(F &&f)
Definition AMReX_EB2_IF_Lathe.H:55
Array< Real, AMREX_SPACEDIM > RealArray
Definition AMReX_Array.H:26
Definition AMReX_EB2_IF_Base.H:15