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_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
10// For all implicit functions, >0: body; =0: boundary; <0: fluid
11
12namespace amrex::EB2 {
13
15 : GPUable
16{
17public:
18 // inside: is the fluid inside the cylinder?
19
23 CylinderIF (Real a_radius, int a_direction,
24 const RealArray& a_center, bool a_inside)
25 : CylinderIF(a_radius, -1.0_rt, a_direction, a_center, a_inside)
26 { }
27
31 CylinderIF (Real a_radius, Real a_height, int a_direction,
32 const RealArray& a_center, bool a_inside)
33 : m_radius(a_radius), m_height(a_height), m_direction(a_direction),
34 m_center(makeXDim3(a_center)),
35 m_sign(a_inside ? 1.0_rt : -1.0_rt)
36 {
37 AMREX_ASSERT(m_direction < AMREX_SPACEDIM);
38 }
39
40 [[nodiscard]] AMREX_GPU_HOST_DEVICE inline
41 Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept
42 {
43#if (AMREX_SPACEDIM == 3)
44 XDim3 pos{x-m_center.x, y-m_center.y, z-m_center.z};
45#else
46 XDim3 pos{x-m_center.x, y-m_center.y, 0.0_rt};
47#endif
48 Real d2 = 0.0_rt;
49 Real pdir;
50 switch (m_direction) {
51 case 0 :
52 {
53#if (AMREX_SPACEDIM == 3)
54 d2 = pos.y*pos.y+pos.z*pos.z;
55#elif (AMREX_SPACEDIM == 2)
56 d2 = pos.y*pos.y;
57#endif
58 pdir = pos.x;
59 break;
60 }
61 case 1:
62 {
63#if (AMREX_SPACEDIM == 3)
64 d2 = pos.x*pos.x+pos.z*pos.z;
65#elif (AMREX_SPACEDIM == 2)
66 d2 = pos.x*pos.x;
67#endif
68 pdir = pos.y;
69 break;
70 }
71 default:
72 {
73 d2 = pos.x*pos.x+pos.y*pos.y;
74#if (AMREX_SPACEDIM == 3)
75 pdir = pos.z;
76#else
77 pdir = 0.0_rt;
78#endif
79 break;
80 }
81 }
82
83 d2 -= m_radius*m_radius;
84
85 if (m_height < 0.0_rt) {
86 return d2*m_sign;
87 } else {
88 Real rtop = ( pdir - 0.5_rt*m_height);
89 Real rbot = (-pdir - 0.5_rt*m_height);
90 Real r = amrex::max(d2,rtop,rbot);
91 return r*m_sign;
92 }
93 }
94
95 [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept
96 {
97 return this->operator() (AMREX_D_DECL(p[0], p[1], p[2]));
98 }
99
100protected:
101
106 //
107 Real m_sign;
108};
109
110}
111
112#endif
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
Definition AMReX_EB2_IF_Cylinder.H:16
AMREX_GPU_HOST_DEVICE Real operator()(AMREX_D_DECL(Real x, Real y, Real z)) const noexcept
Definition AMReX_EB2_IF_Cylinder.H:41
XDim3 m_center
Definition AMReX_EB2_IF_Cylinder.H:105
CylinderIF(Real a_radius, Real a_height, int a_direction, const RealArray &a_center, bool a_inside)
Definition AMReX_EB2_IF_Cylinder.H:31
Real m_radius
Definition AMReX_EB2_IF_Cylinder.H:102
int m_direction
Definition AMReX_EB2_IF_Cylinder.H:104
CylinderIF(Real a_radius, int a_direction, const RealArray &a_center, bool a_inside)
Definition AMReX_EB2_IF_Cylinder.H:23
Real m_sign
Definition AMReX_EB2_IF_Cylinder.H:107
Real m_height
Definition AMReX_EB2_IF_Cylinder.H:103
Definition AMReX_FabArrayBase.H:32
XDim3 makeXDim3(const Array< Real, AMREX_SPACEDIM > &a) noexcept
Definition AMReX_Array.H:885
Array< Real, AMREX_SPACEDIM > RealArray
Definition AMReX_Array.H:26
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr const T & max(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:35
Definition AMReX_EB2_IF_Base.H:11
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