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.)})
45 if ( amrex::almostEqual(
m_vertex[i][0],a_v[0]) && amrex::almostEqual(
m_vertex[i][1],a_v[1])
46 && amrex::almostEqual(
m_vertex[i][2],a_v[2]) ) {
55 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
58 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
82 amrex::Array<amrex::RealVect,m_max_vertices> vertex_cent;
88 m_zdir = vertex_cent[0].crossProduct(vertex_cent[i]);
89 if ( !amrex::almostEqual(
m_zdir.vectorLength(),0.) ) {
break; }
91 AMREX_ALWAYS_ASSERT(!amrex::almostEqual(
m_zdir.vectorLength(), 0.));
97 m_theta[i] = std::atan2(
m_zdir.dotProduct( vertex_cent[0].crossProduct(vertex_cent[i]) ),
98 vertex_cent[0].dotProduct(vertex_cent[i]));
109 amrex::Swap(vertex_cent[j], vertex_cent[j+1]);
118 amrex::RealVect vi_cross_vj = vertex_cent[i].crossProduct(vertex_cent[j]);
119 m_area += 0.5*vi_cross_vj.vectorLength();
121 AMREX_ALWAYS_ASSERT(
m_area > 0. );
124 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
125 int ok ( ) const noexcept
128 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
130 AMREX_ALWAYS_ASSERT(
ok() );
135 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
138 amrex::RealVect x0 = a_point -
m_vertex[0];
139 return amrex::Math::abs(x0.dotProduct(
m_zdir));
143 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
145 amrex::RealVect cent(0.);
154 amrex::RealVect v0_cross_v1 = v0.crossProduct(v1);
155 amrex::Real area_tri = 0.5 * v0_cross_v1.vectorLength();
158 cent += area_tri * cent_tri;
166 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
167 amrex::RealVect
normal () const noexcept {
171 #ifndef AMREX_USE_GPU
172 void report (
int const a_id, amrex::RealVect a_v0 )
174 void report (
int const , amrex::RealVect )
178 #ifndef AMREX_USE_GPU
180 amrex::Print() <<
"Face " << a_id
181 <<
" -------------------------------------------\n"
182 <<
"\nok? " << (
ok() ?
"yes" :
"no") <<
"\n\n";
184 amrex::Print() <<
"v" << i <<
": " <<
m_vertex[i] <<
'\n';
186 amrex::Print() <<
"\nvc: " <<
" " << centroid <<
"\n";
191 amrex::Print() <<
"\narea: " <<
m_area
192 <<
"\ndistance: " << dist
193 <<
"\nvolume: " << dist*
m_area
194 <<
"\n==================================================\n\n";
199 amrex::Print() <<
"EBPolygon: id = " << a_id <<
", m_vertices = " <<
m_vertices <<
'\n';
201 amrex::Print() <<
"EBPolygon: v" << i <<
": " <<
m_vertex[i] <<
'\n';
225 amrex::Array<amrex::RealVect,m_max_vertices>
m_vertex;
227 amrex::GpuArray<amrex::Real,m_max_vertices>
m_theta;
constexpr amrex::Real PI
Definition: ERF_Constants.H:6
amrex::Real Real
Definition: ERF_ShocInterface.H:16
Definition: ERF_EBPolygon.H:9
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect get_centroid() const noexcept
Definition: ERF_EBPolygon.H:144
int m_defined
Definition: ERF_EBPolygon.H:217
amrex::Real m_area
Definition: ERF_EBPolygon.H:221
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int ok() const noexcept
Definition: ERF_EBPolygon.H:125
amrex::GpuArray< amrex::Real, m_max_vertices > m_theta
Definition: ERF_EBPolygon.H:227
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:136
void debug(int const a_id)
Definition: ERF_EBPolygon.H:198
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real area() const noexcept
Definition: ERF_EBPolygon.H:129
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void set_area(amrex::Real const &a_area)
Definition: ERF_EBPolygon.H:56
void debug()
Definition: ERF_EBPolygon.H:204
int const m_cell_face
Definition: ERF_EBPolygon.H:212
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect normal() const noexcept
Definition: ERF_EBPolygon.H:167
int m_sorted
Definition: ERF_EBPolygon.H:223
int m_vertices
Definition: ERF_EBPolygon.H:219
amrex::Array< amrex::RealVect, m_max_vertices > m_vertex
Definition: ERF_EBPolygon.H:225
amrex::RealVect const m_eb_normal
Definition: ERF_EBPolygon.H:215
static constexpr int m_max_vertices
Definition: ERF_EBPolygon.H:210
void report(int const a_id, amrex::RealVect a_v0)
Definition: ERF_EBPolygon.H:172
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void define()
Definition: ERF_EBPolygon.H:59
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:214
amrex::RealVect m_zdir
Definition: ERF_EBPolygon.H:229