1 #ifndef ERF_EB_CUT_CELL_H_
2 #define ERF_EB_CUT_CELL_H_
4 #include <AMReX_REAL.H>
5 #include <AMReX_RealBox.H>
6 #include <AMReX_RealVect.H>
7 #include <AMReX_EBCellFlag.H>
18 amrex::RealBox
const& a_rbox,
19 amrex::RealVect
const& a_point,
20 amrex::RealVect
const& a_normal );
22 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
25 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
28 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
31 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
34 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
52 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
55 if (
m_flag.isCovered() ) {
return 0.; }
60 amrex::Real
const* lo =
m_rbox.lo();
61 amrex::RealVect v0(lo[0], lo[1], lo[2]);
73 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
74 amrex::Real
areaLo (
int const a_idim )
const noexcept {
75 AMREX_ASSERT( a_idim >0 && a_idim < AMREX_SPACEDIM );
76 if (
m_flag.isCovered() ) {
return 0.; }
77 if (
m_flag.isRegular() ) {
return 1.; }
78 amrex::Real
const area(
m_lo_faces[a_idim]->area());
82 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
83 amrex::Real
areaHi (
int const a_idim )
const noexcept {
84 AMREX_ASSERT( a_idim > 0 && a_idim < AMREX_SPACEDIM );
85 if (
m_flag.isCovered() ) {
return 0.; }
86 if (
m_flag.isRegular() ) {
return 1.; }
87 amrex::Real
const area(
m_hi_faces[a_idim]->area());
91 void debug (
int const a_face = -1 );
120 AMREX_GPU_HOST_DEVICE
125 AMREX_GPU_HOST_DEVICE
129 amrex::RealBox
const& a_rbox,
130 amrex::RealVect
const& a_point,
131 amrex::RealVect
const& a_normal )
133 , m_eb_point(a_point)
134 , m_eb_normal(a_normal)
136 , m_F1(a_point, a_normal)
137 , m_F2(a_point, a_normal)
138 , m_F3(a_point, a_normal)
139 , m_F4(a_point, a_normal)
140 , m_F5(a_point, a_normal)
141 , m_F6(a_point, a_normal)
143 using namespace amrex;
149 RealVect v0(a_rbox.lo(0), a_rbox.lo(1), a_rbox.lo(2));
150 RealVect v7(a_rbox.hi(0), a_rbox.hi(1), a_rbox.hi(2));
152 if (a_flag.isCovered() ) {
156 }
else if (a_flag.isRegular() ) {
162 RealVect c = 0.5*(v0 + v7);
165 Real r = e[0]*amrex::Math::abs(a_normal[0]) +
166 e[1]*amrex::Math::abs(a_normal[1]) +
167 e[2]*amrex::Math::abs(a_normal[2]);
169 Real s = amrex::Math::abs(c.dotProduct(a_normal)
170 - a_point.dotProduct(a_normal));
173 if (a_normal.dotProduct(v0 - a_point) > 0.)
175 }
else {
m_flag.setSingleValued(); }
178 if (
m_flag.isSingleValued() ) {
196 AMREX_GPU_HOST_DEVICE
202 using namespace amrex;
230 #ifndef AMREX_USE_GPU
231 if (a_dry_run) { Print() <<
"P1: v0--v1: add vIP to F1, F5 and F7 :: " << vIP[0] <<
"\n"; }
240 if ( almostEqual(distIP, 0.0) ) {
241 #ifndef AMREX_USE_GPU
242 if (a_dry_run) { Print() <<
"P1: v0--v1: intersection ~ 0 :: add vIP to F4\n"; }
247 }
else if ( almostEqual(distIP, 1.0) ) {
248 #ifndef AMREX_USE_GPU
249 if (a_dry_run) { Print() <<
"P1: v0--v1: intersection ~ 1 :: add vIP to F2\n"; }
259 #ifndef AMREX_USE_GPU
260 if (a_dry_run) { Print() <<
"P1: Add v1 to F1, F2 and F5\n"; }
274 #ifndef AMREX_USE_GPU
275 if (a_dry_run) { Print() <<
"P1: v1--v4: add vIP to F2, F5 and F7 :: " << vIP[2] <<
"\n"; }
284 if ( almostEqual(distIP, 0.0) ) {
285 #ifndef AMREX_USE_GPU
286 if (a_dry_run) { Print() <<
"P1: v1--v4: intersection ~ 0 :: add vIP to F1\n"; }
291 }
else if ( almostEqual(distIP, 1.0) ) {
292 #ifndef AMREX_USE_GPU
293 if (a_dry_run) { Print() <<
"P1: v1--v4: intersection ~ 1 :: add vIP to F3\n"; }
303 #ifndef AMREX_USE_GPU
304 if (a_dry_run) { Print() <<
"P1: Add v4 to F2, F3 and F5\n"; }
318 #ifndef AMREX_USE_GPU
319 if (a_dry_run) { Print() <<
"P1: v4--v7: add vIP to F2, F3 and F7 :: " << vIP[1] <<
"\n"; }
328 if ( almostEqual(distIP, 0.0)) {
329 #ifndef AMREX_USE_GPU
330 if (a_dry_run) { Print() <<
"P1: v4--v7: intersection ~ 0 :: add vIP to F5\n"; }
335 }
else if ( almostEqual(distIP, 1.0)) {
336 #ifndef AMREX_USE_GPU
337 if (a_dry_run) { Print() <<
"P1: v4--v7: intersection ~ 1 :: add vIP to F6\n"; }
344 if (cuts == 2 && add_v7) {
346 #ifndef AMREX_USE_GPU
347 if (a_dry_run) { Print() <<
"P1: Add v7 to F2, F3 and F6\n"; }
363 #ifndef AMREX_USE_GPU
364 if (a_dry_run) { Print() <<
"P4: v1--v5: add vIP to F1, F2 and F7 :: " << vIP[1] <<
"\n"; }
373 if ( almostEqual(distIP, 0.0)) {
374 #ifndef AMREX_USE_GPU
375 if (a_dry_run) { Print() <<
"P1: v1--v5: intersection ~ 0 :: add vIP to F5\n"; }
380 }
else if ( almostEqual(distIP, 1.0)) {
381 #ifndef AMREX_USE_GPU
382 if (a_dry_run) { Print() <<
"P1: v1--v5: intersection ~ 1 :: add vIP to F6\n"; }
397 #ifndef AMREX_USE_GPU
398 if (a_dry_run) { Print() <<
"P2: v0--v2: add vIP to F1, F4 and F7 :: " << vIP[1] <<
"\n"; }
407 if ( almostEqual(distIP, 0.0)) {
408 #ifndef AMREX_USE_GPU
409 if (a_dry_run) { Print() <<
"P2: v0--v2: intersection ~ 0 :: add vIP to F5\n"; }
414 }
else if ( almostEqual(distIP, 1.0)) {
415 #ifndef AMREX_USE_GPU
416 if (a_dry_run) { Print() <<
"P2: v0--v2: intersection ~ 1 :: add vIP to F6\n"; }
426 #ifndef AMREX_USE_GPU
427 if (a_dry_run) { Print() <<
"P2: Add v2 to F1, F4, F6\n"; }
441 #ifndef AMREX_USE_GPU
442 if (a_dry_run) { Print() <<
"P2: v2--v5: add vIP to F1, F6 and F7 :: " << vIP[0] <<
"\n"; }
451 if ( almostEqual(distIP, 0.0)) {
452 #ifndef AMREX_USE_GPU
453 if (a_dry_run) { Print() <<
"P2: v2--v5: intersection ~ 0 :: add vIP to F4\n"; }
458 }
else if ( almostEqual(distIP, 1.0)) {
459 #ifndef AMREX_USE_GPU
460 if (a_dry_run) { Print() <<
"P2: v2--v5: intersection ~ 1 :: add vIP to F2\n"; }
469 #ifndef AMREX_USE_GPU
470 if (a_dry_run) { Print() <<
"P2: Add v5 to F1, F2 and F6\n"; }
484 #ifndef AMREX_USE_GPU
485 if (a_dry_run) { Print() <<
"P2: v5--v7: add vIP to F2, F6 and F7 :: " << vIP[2] <<
"\n"; }
494 if ( almostEqual(distIP, 0.0)) {
495 #ifndef AMREX_USE_GPU
496 if (a_dry_run) { Print() <<
"P2: v5--v7: intersection ~ 0 :: add vIP to F1\n"; }
501 }
else if ( almostEqual(distIP, 1.0)) {
502 #ifndef AMREX_USE_GPU
503 if (a_dry_run) { Print() <<
"P2: v5--v7: intersection ~ 1 :: add vIP to F3\n"; }
510 if (cuts == 2 && add_v7) {
512 #ifndef AMREX_USE_GPU
513 if (a_dry_run) { Print() <<
"P2: Add v7 to F2, F3 and F6\n"; }
530 #ifndef AMREX_USE_GPU
531 if (a_dry_run) { Print() <<
"P5: v2--v6: add vIP to F4, F6 and F7 :: " << vIP[2] <<
"\n"; }
540 if ( almostEqual(distIP, 0.0)) {
541 #ifndef AMREX_USE_GPU
542 if (a_dry_run) { Print() <<
"P5: v2--v6: intersection ~ 0 :: add vIP to F1\n"; }
547 }
else if ( almostEqual(distIP, 1.0)) {
548 #ifndef AMREX_USE_GPU
549 if (a_dry_run) { Print() <<
"P5: v2--v6: intersection ~ 1 :: add vIP to F3\n"; }
564 #ifndef AMREX_USE_GPU
565 if (a_dry_run) { Print() <<
"P3: v0--v3: add vIP to F4, F5 and F7 :: " << vIP[2] <<
"\n"; }
574 if ( almostEqual(distIP, 0.0)) {
575 #ifndef AMREX_USE_GPU
576 if (a_dry_run) { Print() <<
"P3: v0--v3: intersection ~ 0 :: add vIP to F1\n"; }
581 }
else if ( almostEqual(distIP, 1.0)) {
582 #ifndef AMREX_USE_GPU
583 if (a_dry_run) { Print() <<
"P3: v0--v3: intersection ~ 1 :: add vIP to F3\n"; }
593 #ifndef AMREX_USE_GPU
594 if (a_dry_run) { Print() <<
"P3: Add v3 to F3, F4 and F5\n"; }
608 #ifndef AMREX_USE_GPU
609 if (a_dry_run) { Print() <<
"P3: v3--v6: add vIP to F3, F4 and F7 :: " << vIP[1] <<
"\n"; }
618 if ( almostEqual(distIP, 0.0)) {
619 #ifndef AMREX_USE_GPU
620 if (a_dry_run) { Print() <<
"P3: v3--v6: intersection ~ 0 :: add vIP to F5\n"; }
625 }
else if ( almostEqual(distIP, 1.0)) {
626 #ifndef AMREX_USE_GPU
627 if (a_dry_run) { Print() <<
"P3: v3--v6: intersection ~ 1 :: add vIP to F6\n"; }
637 #ifndef AMREX_USE_GPU
638 if (a_dry_run) { Print() <<
"P3: Add v6 to F3, F4 and F6\n"; }
652 #ifndef AMREX_USE_GPU
653 if (a_dry_run) { Print() <<
"P3: v6--v7: add vIP to F3, F6 and F7 :: " << vIP[0] <<
"\n"; }
662 if ( almostEqual(distIP, 0.0)) {
663 #ifndef AMREX_USE_GPU
664 if (a_dry_run) { Print() <<
"P3: v6--v7: intersection ~ 0 :: add vIP to F4\n"; }
669 }
else if ( almostEqual(distIP, 1.0)) {
670 #ifndef AMREX_USE_GPU
671 if (a_dry_run) { Print() <<
"P3: v6--v7: intersection ~ 1 :: add vIP to F2\n"; }
678 if (cuts == 2 && add_v7) {
680 #ifndef AMREX_USE_GPU
681 if (a_dry_run) { Print() <<
"P1: Add v7 to F2, F3 and F6\n"; }
696 #ifndef AMREX_USE_GPU
697 if (a_dry_run) { Print() <<
"P6: v3--v4: add vIP to F3, F5 and F7 :: " << vIP[0] <<
"\n"; }
706 if ( almostEqual(distIP, 0.0)) {
707 #ifndef AMREX_USE_GPU
708 if (a_dry_run) { Print() <<
"P6: v3--v4: intersection ~ 0 :: add vIP to F4\n"; }
713 }
else if ( almostEqual(distIP, 1.0)) {
714 #ifndef AMREX_USE_GPU
715 if (a_dry_run) { Print() <<
"P6: v3--v4: intersection ~ 1 :: add vIP to F2\n"; }
Definition: ERF_EBCutCell.H:12
polygon_ m_F6
Definition: ERF_EBCutCell.H:112
amrex::Array< polygon_ const *const, 3 > m_lo_faces
Definition: ERF_EBCutCell.H:117
amrex::RealVect m_rbox_area
Definition: ERF_EBCutCell.H:101
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isRegular() const noexcept
Definition: ERF_EBCutCell.H:26
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real areaHi(int const a_idim) const noexcept
Definition: ERF_EBCutCell.H:83
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real areaLo(int const a_idim) const noexcept
Definition: ERF_EBCutCell.H:74
amrex::RealVect const m_eb_point
Definition: ERF_EBCutCell.H:96
amrex::Real m_invert
Definition: ERF_EBCutCell.H:99
amrex::RealBox const m_rbox
Definition: ERF_EBCutCell.H:95
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void set_regular()
Definition: ERF_EBCutCell.H:35
polygon_ m_F1
Definition: ERF_EBCutCell.H:107
polygon_ m_F3
Definition: ERF_EBCutCell.H:109
amrex::EBCellFlag m_flag
Definition: ERF_EBCutCell.H:103
AMREX_GPU_HOST_DEVICE void calc_edge_intersections(int const a_dry_run=0)
Definition: ERF_EBCutCell.H:200
polygon_ m_F5
Definition: ERF_EBCutCell.H:111
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void set_covered()
Definition: ERF_EBCutCell.H:32
polygon_ m_F7
Definition: ERF_EBCutCell.H:115
AMREX_GPU_HOST_DEVICE eb_cut_cell_(amrex::EBCellFlag const &a_flag, amrex::RealBox const &a_rbox, amrex::RealVect const &a_point, amrex::RealVect const &a_normal)
Definition: ERF_EBCutCell.H:128
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isSingleValued() const noexcept
Definition: ERF_EBCutCell.H:29
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real volume()
Definition: ERF_EBCutCell.H:53
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isCovered() const noexcept
Definition: ERF_EBCutCell.H:23
void debug(int const a_face=-1)
Definition: ERF_EBCutCell.cpp:9
amrex::RealVect const m_eb_normal
Definition: ERF_EBCutCell.H:97
polygon_ m_F2
Definition: ERF_EBCutCell.H:108
amrex::Array< polygon_ const *const, 3 > m_hi_faces
Definition: ERF_EBCutCell.H:118
polygon_ m_F4
Definition: ERF_EBCutCell.H:110
Definition: ERF_EBPolygon.H:9
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int ok() const noexcept
Definition: ERF_EBPolygon.H:119
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
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void define()
Definition: ERF_EBPolygon.H:53
Definition: ERF_ConsoleIO.cpp:12
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int intersect_plane_edge(amrex::RealVect const &a_plane_point, amrex::RealVect const &a_plane_normal, amrex::RealVect const &a_edge_point0, amrex::RealVect const &a_edge_point1, amrex::RealVect &a_intersection_point, amrex::Real &a_intersection_dist)
Definition: ERF_EBUtils.H:30