Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_EB2_IF_Difference.H
Go to the documentation of this file.
1#ifndef AMREX_EB2_IF_DIFFERENCE_H_
2#define AMREX_EB2_IF_DIFFERENCE_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 <algorithm>
10#include <utility>
11
18// For all implicit functions, >0: body; =0: boundary; <0: fluid
19
20namespace amrex::EB2 {
21
22template <class F, class G>
25{
26public:
27
29 DifferenceIF (F a_f, G a_g)
30 : m_f(std::move(a_f)),
31 m_g(std::move(a_g))
32 {}
33
35 [[nodiscard]] AMREX_FORCE_INLINE Real operator() (const RealArray& p) const noexcept
36 {
37 Real r1 = m_f(p);
38 Real r2 = m_g(p);
39 return amrex::min(r1, -r2);
40 }
41
43 template <class U=F, class V=G,
44 std::enable_if_t<IsGPUable<U>::value &&
45 IsGPUable<V>::value, int> = 0>
48 {
49 Real r1 = m_f(AMREX_D_DECL(x,y,z));
50 Real r2 = m_g(AMREX_D_DECL(x,y,z));
51 return amrex::min(r1, -r2);
52 }
53
54protected:
55
57 G m_g;
58};
59
60template <class F, class G>
61struct IsGPUable<DifferenceIF<F,G>, std::enable_if_t<IsGPUable<F>::value &&
62 IsGPUable<G>::value>>
63 : std::true_type {};
64
65template <class F, class G>
68 std::decay_t<G>>
69makeDifference (F&& f, G&& g)
70{
72 std::decay_t<G>>
73 (std::forward<F>(f), std::forward<G>(g));
74}
75
76}
77
78#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
Implicit function that keeps points inside F but outside G.
Definition AMReX_EB2_IF_Difference.H:25
DifferenceIF(F a_f, G a_g)
Store the minuend a_f and subtrahend a_g implicit functions.
Definition AMReX_EB2_IF_Difference.H:29
Real operator()(const RealArray &p) const noexcept
Evaluate the set difference at p.
Definition AMReX_EB2_IF_Difference.H:35
G m_g
Definition AMReX_EB2_IF_Difference.H:57
F m_f
Definition AMReX_EB2_IF_Difference.H:56
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
Definition AMReX_FabArrayBase.H:33
constexpr DifferenceIF< std::decay_t< F >, std::decay_t< G > > makeDifference(F &&f, G &&g)
Helper that constructs a difference operator.
Definition AMReX_EB2_IF_Difference.H:69
__host__ __device__ constexpr const T & min(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:24
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