5 #ifndef ERF_EB_POLYGON_H_
6 #define ERF_EB_POLYGON_H_
8 #include <AMReX_REAL.H>
9 #include <AMReX_RealVect.H>
30 amrex::RealVect a_normal )
39 amrex::RealVect(
zero), amrex::RealVect(
zero), amrex::RealVect(
zero)})
54 amrex::RealVect(
zero), amrex::RealVect(
zero), amrex::RealVect(
zero)})
65 if ( amrex::almostEqual(
m_vertices[i][0],a_v[0]) &&
67 amrex::almostEqual(
m_vertices[i][2],a_v[2]) ) {
86 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
95 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
119 amrex::Array<amrex::RealVect,m_max_vertices> vertex_cent;
126 amrex::RealVect v_normal;
128 const amrex::RealVect& vertex_cent_0 = vertex_cent[0];
132 amrex::RealVect
vi = vertex_cent[i];
133 amrex::RealVect v_cross = vertex_cent_0.crossProduct(
vi);
141 if (!amrex::almostEqual(max_norm2,
zero))
143 v_normal /= std::sqrt(max_norm2);
152 m_theta[i] = std::atan2(
m_zdir.dotProduct( vertex_cent[0].crossProduct(vertex_cent[i]) ),
153 vertex_cent[0].dotProduct(vertex_cent[i]));
164 amrex::Swap(vertex_cent[j], vertex_cent[j+1]);
174 amrex::RealVect vi_cross_vj = vertex_cent[i].crossProduct(vertex_cent[j]);
181 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
182 int ok ( ) const noexcept
186 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
196 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
200 return amrex::Math::abs(x0.dotProduct(
m_zdir));
204 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
206 amrex::RealVect cent(
zero);
215 amrex::RealVect v0_cross_v1 = v0.crossProduct(v1);
219 cent += area_tri * cent_tri;
227 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
228 amrex::RealVect
normal () const noexcept {
237 #ifndef AMREX_USE_GPU
238 void report (
int const a_id, amrex::RealVect a_v0 )
240 void report (
int const , amrex::RealVect )
244 #ifndef AMREX_USE_GPU
246 amrex::Print() <<
"Face " << a_id
247 <<
" -------------------------------------------\n"
248 <<
"\nok? " << (
ok() ?
"yes" :
"no") <<
"\n\n";
250 amrex::Print() <<
"v" << i <<
": " <<
m_vertices[i] <<
'\n';
252 amrex::Print() <<
"\nvc: " <<
" " << centroid <<
"\n";
257 amrex::Print() <<
"\narea: " <<
m_area
258 <<
"\ndistance: " << dist
259 <<
"\nvolume: " << dist*
m_area
260 <<
"\n==================================================\n\n";
269 amrex::Print() <<
"EBPolygon: id = " << a_id <<
", m_num_vertices = " <<
m_num_vertices <<
'\n';
271 amrex::Print() <<
"EBPolygon: v" << i <<
": " <<
m_vertices[i] <<
'\n';
298 amrex::GpuArray<amrex::Real,m_max_vertices>
m_theta;
constexpr amrex::Real three
Definition: ERF_Constants.H:11
constexpr amrex::Real two
Definition: ERF_Constants.H:10
constexpr amrex::Real one
Definition: ERF_Constants.H:9
constexpr amrex::Real zero
Definition: ERF_Constants.H:8
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:13
constexpr amrex::Real PI
Definition: ERF_Constants.H:42
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
amrex::Real Real
Definition: ERF_ShocInterface.H:19
Polygon helper used to accumulate cut-cell face geometry.
Definition: ERF_EBPolygon.H:19
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect get_centroid() const noexcept
Return the polygon centroid from its sub-triangulation.
Definition: ERF_EBPolygon.H:205
int m_defined
Definition: ERF_EBPolygon.H:288
AMREX_GPU_HOST_DEVICE int get_num_vertices()
Return the number of stored vertices.
Definition: ERF_EBPolygon.H:78
amrex::Real m_area
Definition: ERF_EBPolygon.H:292
amrex::Array< amrex::RealVect, m_max_vertices > m_vertices
Definition: ERF_EBPolygon.H:296
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int ok() const noexcept
Return whether the polygon has been defined with a valid area state.
Definition: ERF_EBPolygon.H:182
amrex::GpuArray< amrex::Real, m_max_vertices > m_theta
Definition: ERF_EBPolygon.H:298
AMREX_GPU_HOST_DEVICE void add_vertex(amrex::RealVect const &a_v)
Add a unique vertex to the polygon.
Definition: ERF_EBPolygon.H:63
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real distance(amrex::RealVect const &a_point) const noexcept
Return the perpendicular distance from this polygon to a point.
Definition: ERF_EBPolygon.H:197
void debug(int const a_id)
Print polygon vertices with a face identifier.
Definition: ERF_EBPolygon.H:268
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real area() const noexcept
Return the polygon area.
Definition: ERF_EBPolygon.H:187
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void set_area(amrex::Real const &a_area)
Set the polygon area directly.
Definition: ERF_EBPolygon.H:87
void debug()
Print polygon vertices without a face identifier.
Definition: ERF_EBPolygon.H:275
int const m_cell_face
Definition: ERF_EBPolygon.H:283
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect normal() const noexcept
Return the unit normal vector of the polygon plane.
Definition: ERF_EBPolygon.H:228
int m_sorted
Definition: ERF_EBPolygon.H:294
amrex::RealVect const m_eb_normal
Definition: ERF_EBPolygon.H:286
static constexpr int m_max_vertices
Definition: ERF_EBPolygon.H:281
void report(int const a_id, amrex::RealVect a_v0)
Print a diagnostic report for the polygon on CPU builds.
Definition: ERF_EBPolygon.H:238
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void define()
Finalize polygon ordering and compute its area.
Definition: ERF_EBPolygon.H:96
int m_num_vertices
Definition: ERF_EBPolygon.H:290
AMREX_GPU_HOST_DEVICE polygon_()
Construct an empty EB-boundary polygon.
Definition: ERF_EBPolygon.H:45
AMREX_GPU_HOST_DEVICE polygon_(amrex::RealVect a_point, amrex::RealVect a_normal)
Construct a cell-face polygon clipped by an EB plane.
Definition: ERF_EBPolygon.H:29
amrex::RealVect const m_eb_point
Definition: ERF_EBPolygon.H:285
amrex::RealVect m_zdir
Definition: ERF_EBPolygon.H:300
real(c_double), private vi
Definition: ERF_module_mp_morr_two_moment.F90:219