1 #ifndef ERF_EB_POLYGON_H_
2 #define ERF_EB_POLYGON_H_
4 #include <AMReX_REAL.H>
5 #include <AMReX_RealVect.H>
15 amrex::RealVect a_normal )
23 ,
m_vertex({amrex::RealVect(0.), amrex::RealVect(0.), amrex::RealVect(0.),
24 amrex::RealVect(0.), amrex::RealVect(0.), amrex::RealVect(0.)})
37 ,
m_vertex({amrex::RealVect(0.), amrex::RealVect(0.), amrex::RealVect(0.),
38 amrex::RealVect(0.), amrex::RealVect(0.), amrex::RealVect(0.)})
49 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
52 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
76 amrex::Array<amrex::RealVect,m_max_vertices> vertex_cent;
82 m_zdir = vertex_cent[0].crossProduct(vertex_cent[i]);
83 if ( !amrex::almostEqual(
m_zdir.vectorLength(),0.) ) {
break; }
85 AMREX_ALWAYS_ASSERT(!amrex::almostEqual(
m_zdir.vectorLength(), 0.));
91 m_theta[i] = std::atan2(
m_zdir.dotProduct( vertex_cent[0].crossProduct(vertex_cent[i]) ),
92 vertex_cent[0].dotProduct(vertex_cent[i]));
103 amrex::Swap(vertex_cent[j], vertex_cent[j+1]);
112 amrex::RealVect vi_cross_vj = vertex_cent[i].crossProduct(vertex_cent[j]);
113 m_area += 0.5*vi_cross_vj.vectorLength();
115 AMREX_ALWAYS_ASSERT(
m_area > 0. );
118 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
119 int ok ( ) const noexcept
122 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
123 amrex::Real
area ( ) const noexcept {
124 AMREX_ALWAYS_ASSERT(
ok() );
129 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
130 amrex::Real
distance ( amrex::RealVect
const& a_point )
const noexcept {
132 amrex::RealVect x0 = a_point -
m_vertex[0];
133 return amrex::Math::abs(x0.dotProduct(
m_zdir));
137 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
139 amrex::RealVect cent(0.);
141 return cent /
static_cast<amrex::Real
>(
m_vertices);
144 #ifndef AMREX_USE_GPU
145 void report (
int const a_id, amrex::RealVect a_v0 )
147 void report (
int const , amrex::RealVect )
151 #ifndef AMREX_USE_GPU
153 amrex::Print() <<
"Face " << a_id
154 <<
" -------------------------------------------\n"
155 <<
"\nok? " << (
ok() ?
"yes" :
"no") <<
"\n\n";
157 amrex::Print() <<
"v" << i <<
": " <<
m_vertex[i] <<
'\n';
159 amrex::Print() <<
"\nvc: " <<
" " << centroid <<
"\n";
161 amrex::Real
const dist =
distance( a_v0 );
164 amrex::Print() <<
"\narea: " <<
m_area
165 <<
"\ndistance: " << dist
166 <<
"\nvolume: " << dist*
m_area
167 <<
"\n==================================================\n\n";
188 amrex::Array<amrex::RealVect,m_max_vertices>
m_vertex;
190 amrex::GpuArray<amrex::Real,m_max_vertices>
m_theta;
constexpr amrex::Real PI
Definition: ERF_Constants.H:6
Definition: ERF_EBPolygon.H:9
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect get_centroid() const noexcept
Definition: ERF_EBPolygon.H:138
int m_defined
Definition: ERF_EBPolygon.H:180
amrex::Real m_area
Definition: ERF_EBPolygon.H:184
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int ok() const noexcept
Definition: ERF_EBPolygon.H:119
amrex::GpuArray< amrex::Real, m_max_vertices > m_theta
Definition: ERF_EBPolygon.H:190
AMREX_GPU_HOST_DEVICE void add_vertex(amrex::RealVect const &a_v)
Definition: ERF_EBPolygon.H:43
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real distance(amrex::RealVect const &a_point) const noexcept
Definition: ERF_EBPolygon.H:130
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real area() const noexcept
Definition: ERF_EBPolygon.H:123
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void set_area(amrex::Real const &a_area)
Definition: ERF_EBPolygon.H:50
int const m_cell_face
Definition: ERF_EBPolygon.H:175
int m_sorted
Definition: ERF_EBPolygon.H:186
int m_vertices
Definition: ERF_EBPolygon.H:182
amrex::Array< amrex::RealVect, m_max_vertices > m_vertex
Definition: ERF_EBPolygon.H:188
amrex::RealVect const m_eb_normal
Definition: ERF_EBPolygon.H:178
static constexpr int m_max_vertices
Definition: ERF_EBPolygon.H:173
void report(int const a_id, amrex::RealVect a_v0)
Definition: ERF_EBPolygon.H:145
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void define()
Definition: ERF_EBPolygon.H:53
AMREX_GPU_HOST_DEVICE polygon_()
Definition: ERF_EBPolygon.H:29
AMREX_GPU_HOST_DEVICE polygon_(amrex::RealVect a_point, amrex::RealVect a_normal)
Definition: ERF_EBPolygon.H:14
amrex::RealVect const m_eb_point
Definition: ERF_EBPolygon.H:177
amrex::RealVect m_zdir
Definition: ERF_EBPolygon.H:192