Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_EB2_IF_Cylinder.H
Go to the documentation of this file.
1#ifndef AMREX_EB2_IF_CYLINDER_H_
2#define AMREX_EB2_IF_CYLINDER_H_
3#include <AMReX_Config.H>
4
5#include <AMReX_Array.H>
6#include <AMReX_EB2_IF_Base.H>
7
8#include <algorithm>
9
16// For all implicit functions, >0: body; =0: boundary; <0: fluid
17
18namespace amrex::EB2 {
19
22 : GPUable
23{
24public:
26 CylinderIF (Real a_radius, int a_direction,
27 const RealArray& a_center, bool a_inside)
28 : CylinderIF(a_radius, -1.0_rt, a_direction, a_center, a_inside)
29 { }
30
32 CylinderIF (Real a_radius, Real a_height, int a_direction,
33 const RealArray& a_center, bool a_inside)
34 : m_radius(a_radius), m_height(a_height), m_direction(a_direction),
35 m_center(makeXDim3(a_center)),
36 m_sign(a_inside ? 1.0_rt : -1.0_rt)
37 {
38 AMREX_ASSERT(m_direction < AMREX_SPACEDIM);
39 }
40
43 {
44#if (AMREX_SPACEDIM == 3)
46#else
47 XDim3 pos{x-m_center.x, y-m_center.y, 0.0_rt};
48#endif
49 Real d2 = 0.0_rt;
50 Real pdir;
51 switch (m_direction) {
52 case 0 :
53 {
54#if (AMREX_SPACEDIM == 3)
55 d2 = pos.y*pos.y+pos.z*pos.z;
56#elif (AMREX_SPACEDIM == 2)
57 d2 = pos.y*pos.y;
58#endif
59 pdir = pos.x;
60 break;
61 }
62 case 1:
63 {
64#if (AMREX_SPACEDIM == 3)
65 d2 = pos.x*pos.x+pos.z*pos.z;
66#elif (AMREX_SPACEDIM == 2)
67 d2 = pos.x*pos.x;
68#endif
69 pdir = pos.y;
70 break;
71 }
72 default:
73 {
74 d2 = pos.x*pos.x+pos.y*pos.y;
75#if (AMREX_SPACEDIM == 3)
76 pdir = pos.z;
77#else
78 pdir = 0.0_rt;
79#endif
80 break;
81 }
82 }
83
84 d2 -= m_radius*m_radius;
85
86 if (m_height < 0.0_rt) {
87 return d2*m_sign;
88 } else {
89 Real rtop = ( pdir - 0.5_rt*m_height);
90 Real rbot = (-pdir - 0.5_rt*m_height);
91 Real r = amrex::max(d2,rtop,rbot);
92 return r*m_sign;
93 }
94 }
95
97 [[nodiscard]] AMREX_FORCE_INLINE Real operator() (const RealArray& p) const noexcept
98 {
99 return this->operator() (AMREX_D_DECL(p[0], p[1], p[2]));
100 }
101
102protected:
103
108 //
110};
111
112}
113
114#endif
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
#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
Signed implicit function for cylinders along a coordinate axis.
Definition AMReX_EB2_IF_Cylinder.H:23
XDim3 m_center
Definition AMReX_EB2_IF_Cylinder.H:107
CylinderIF(Real a_radius, Real a_height, int a_direction, const RealArray &a_center, bool a_inside)
Build a finite cylinder with height a_height.
Definition AMReX_EB2_IF_Cylinder.H:32
Real m_radius
Definition AMReX_EB2_IF_Cylinder.H:104
int m_direction
Definition AMReX_EB2_IF_Cylinder.H:106
CylinderIF(Real a_radius, int a_direction, const RealArray &a_center, bool a_inside)
Build an infinite cylinder (extends across the domain in its axis direction).
Definition AMReX_EB2_IF_Cylinder.H:26
Real m_sign
Definition AMReX_EB2_IF_Cylinder.H:109
Real m_height
Definition AMReX_EB2_IF_Cylinder.H:105
__host__ __device__ Real operator()(Real x, Real y, Real z) const noexcept
Definition AMReX_EB2_IF_Cylinder.H:42
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
Definition AMReX_FabArrayBase.H:33
XDim3 makeXDim3(const Array< Real, 3 > &a) noexcept
Definition AMReX_Array.H:1092
__host__ __device__ constexpr const T & max(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:44
Array< Real, 3 > RealArray
Definition AMReX_Array.H:28
Marker base that denotes an implicit function callable on device kernels.
Definition AMReX_EB2_IF_Base.H:19
Definition AMReX_Dim3.H:13
Real x
Definition AMReX_Dim3.H:13
Real z
Definition AMReX_Dim3.H:13
Real y
Definition AMReX_Dim3.H:13