5 #ifndef ERF_EB_POLYGON_H_
6 #define ERF_EB_POLYGON_H_
8 #include <AMReX_REAL.H>
9 #include <AMReX_RealVect.H>
31 amrex::RealVect a_normal )
40 amrex::RealVect(
zero), amrex::RealVect(
zero), amrex::RealVect(
zero)})
55 amrex::RealVect(
zero), amrex::RealVect(
zero), amrex::RealVect(
zero)})
66 if ( amrex::almostEqual(
m_vertices[i][0],a_v[0]) &&
68 amrex::almostEqual(
m_vertices[i][2],a_v[2]) ) {
87 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
96 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
120 amrex::Array<amrex::RealVect,m_max_vertices> vertex_cent;
127 amrex::RealVect v_normal;
129 const amrex::RealVect& vertex_cent_0 = vertex_cent[0];
133 amrex::RealVect
vi = vertex_cent[i];
134 amrex::RealVect v_cross = vertex_cent_0.crossProduct(
vi);
142 if (!amrex::almostEqual(max_norm2,
zero))
144 v_normal /= std::sqrt(max_norm2);
153 m_theta[i] = std::atan2(
m_zdir.dotProduct( vertex_cent[0].crossProduct(vertex_cent[i]) ),
154 vertex_cent[0].dotProduct(vertex_cent[i]));
165 amrex::Swap(vertex_cent[j], vertex_cent[j+1]);
175 amrex::RealVect vi_cross_vj = vertex_cent[i].crossProduct(vertex_cent[j]);
182 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
183 int ok ( ) const noexcept
187 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
197 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
201 return amrex::Math::abs(x0.dotProduct(
m_zdir));
205 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
207 amrex::RealVect cent(
zero);
216 amrex::RealVect v0_cross_v1 = v0.crossProduct(v1);
220 cent += area_tri * cent_tri;
228 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
229 amrex::RealVect
normal () const noexcept {
238 #ifndef AMREX_USE_GPU
239 void report (
int const a_id, amrex::RealVect a_v0 )
241 void report (
int const , amrex::RealVect )
245 #ifndef AMREX_USE_GPU
247 amrex::Print() <<
"Face " << a_id
248 <<
" -------------------------------------------\n"
249 <<
"\nok? " << (
ok() ?
"yes" :
"no") <<
"\n\n";
251 amrex::Print() <<
"v" << i <<
": " <<
m_vertices[i] <<
'\n';
253 amrex::Print() <<
"\nvc: " <<
" " << centroid <<
"\n";
258 amrex::Print() <<
"\narea: " <<
m_area
259 <<
"\ndistance: " << dist
260 <<
"\nvolume: " << dist*
m_area
261 <<
"\n==================================================\n\n";
270 amrex::Print() <<
"EBPolygon: id = " << a_id <<
", m_num_vertices = " <<
m_num_vertices <<
'\n';
272 amrex::Print() <<
"EBPolygon: v" << i <<
": " <<
m_vertices[i] <<
'\n';
299 amrex::GpuArray<amrex::Real,m_max_vertices>
m_theta;
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
Dimensionless numeric literals and pure mathematical constants.
constexpr amrex::Real three
Definition: ERF_NumericalConstants.H:32
constexpr amrex::Real two
Definition: ERF_NumericalConstants.H:31
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:30
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:29
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:34
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:39
amrex::Real Real
Definition: ERF_ShocInterface.H:19
Polygon helper used to accumulate cut-cell face geometry.
Definition: ERF_EBPolygon.H:20
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:206
int m_defined
Definition: ERF_EBPolygon.H:289
AMREX_GPU_HOST_DEVICE int get_num_vertices()
Return the number of stored vertices.
Definition: ERF_EBPolygon.H:79
amrex::Real m_area
Definition: ERF_EBPolygon.H:293
amrex::Array< amrex::RealVect, m_max_vertices > m_vertices
Definition: ERF_EBPolygon.H:297
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:183
amrex::GpuArray< amrex::Real, m_max_vertices > m_theta
Definition: ERF_EBPolygon.H:299
AMREX_GPU_HOST_DEVICE void add_vertex(amrex::RealVect const &a_v)
Add a unique vertex to the polygon.
Definition: ERF_EBPolygon.H:64
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:198
void debug(int const a_id)
Print polygon vertices with a face identifier.
Definition: ERF_EBPolygon.H:269
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real area() const noexcept
Return the polygon area.
Definition: ERF_EBPolygon.H:188
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void set_area(amrex::Real const &a_area)
Set the polygon area directly.
Definition: ERF_EBPolygon.H:88
void debug()
Print polygon vertices without a face identifier.
Definition: ERF_EBPolygon.H:276
int const m_cell_face
Definition: ERF_EBPolygon.H:284
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:229
int m_sorted
Definition: ERF_EBPolygon.H:295
amrex::RealVect const m_eb_normal
Definition: ERF_EBPolygon.H:287
static constexpr int m_max_vertices
Definition: ERF_EBPolygon.H:282
void report(int const a_id, amrex::RealVect a_v0)
Print a diagnostic report for the polygon on CPU builds.
Definition: ERF_EBPolygon.H:239
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void define()
Finalize polygon ordering and compute its area.
Definition: ERF_EBPolygon.H:97
int m_num_vertices
Definition: ERF_EBPolygon.H:291
AMREX_GPU_HOST_DEVICE polygon_()
Construct an empty EB-boundary polygon.
Definition: ERF_EBPolygon.H:46
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:30
amrex::RealVect const m_eb_point
Definition: ERF_EBPolygon.H:286
amrex::RealVect m_zdir
Definition: ERF_EBPolygon.H:301
real(c_double), private vi
Definition: ERF_module_mp_morr_two_moment.F90:219