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
46 {
47 Real r1 = m_f(AMREX_D_DECL(x,y,z));
48 Real r2 = m_g(AMREX_D_DECL(x,y,z));
49 return amrex::min(r1, -r2);
50 }
51
52protected:
53
55 G m_g;
56};
57
58template <class F, class G>
60struct IsGPUable<DifferenceIF<F,G>> : std::true_type {};
61
62template <class F, class G>
65 std::decay_t<G>>
66makeDifference (F&& f, G&& g)
67{
69 std::decay_t<G>>
70 (std::forward<F>(f), std::forward<G>(g));
71}
72
73}
74
75#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:55
F m_f
Definition AMReX_EB2_IF_Difference.H:54
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:66
__host__ __device__ constexpr const T & min(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:25
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